SophiaPretty

(5)

$14/per page/Negotiable

About SophiaPretty

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Accounting,Algebra See all
Accounting,Algebra,Applied Sciences,Architecture and Design,Art & Design,Biology,Business & Finance,Calculus,Chemistry,Communications,Computer Science,Economics,Engineering,English,Environmental science,Essay writing Hide all
Teaching Since: Jul 2017
Last Sign in: 314 Weeks Ago
Questions Answered: 15833
Tutorials Posted: 15827

Education

  • MBA,PHD, Juris Doctor
    Strayer,Devery,Harvard University
    Mar-1995 - Mar-2002

Experience

  • Manager Planning
    WalMart
    Mar-2001 - Feb-2009

Category > Computer Science Posted 14 Nov 2017 My Price 10.00

motivation of this programming task is to simulate

Can you help me? I want to know how to write the two programs' code?

 

 

Programming Task 1

 

 

                

For this task, you'll practice writing more classes, and you will apply the concept of class aggregation.

This programming task is very similar to what you did for Lab 2, so review it for hints and pointers. The motivation of this programming task is to simulate a police officer issuing a parking ticket. Create four classes, ParkedCar, ParkingMeter, ParkingTicket, and PoliceOfficer.

 

The ParkedCarclass is meant to hold information about a car's make, model, color, license number, and the number of minutes that the car has been parked. It has two constructors; the first is a constructor that takes five arguments, and the second a copy constructor. Look on page 518 and 519 of the textbook, to review copy constructors.

 

ParkedCar

-  make : String

-  model : String

-  color : String

-  licenseNumber : String

-  minutesParked : int

+ ParkedCar(mk : String, mdel : String, col : String, lic : String, minParked : int) + ParkedCar(car2 : ParkedCar)

 

setter and getter methods, and the toString method, not shown

 

 

 

 

 

 

The ParkingMeterclass is meant to hold information about the number of minutes of parking time that have been purchased.

 

ParkingMeter

- minutesPurchased : int

+ ParkingMeter(numMinPurchased : int)

 

setter and getter methods, and the toString method, not shown

 

The PoliceOfficerclass holds data about the name and badge number of an officer. It has two constructors; the first is a constructor that takes as input two arguments, and a second that is a copy constructor. The class method patrol looks at the number of minutes a car has been parked and the number of minutes purchased. If the minutes parked are greater than the minutes purchased, a ParkingTicketobject is created and returned; otherwise patrol returns null.

 

PoliceOfficer

-  name : String

-  badgeNumber : String

+ PoliceOfficer(officeName : String, badgeNumber : String)

+ PoliceOfficer(officer : PoliceOfficer)

+ patrol(car : ParkedCar, meter : ParkingMeter) : ParkingTicket

 

setter and getter methods, and the toString method, not shown

 

The ParkingTicketclass is an aggregate class; it contains instance fields that are reference variables to ParkedCarand PoliceOfficerobjects. The first constructor takes three arguments, and the second is a copy constructor. The method calculateFinecalculates the amount of a parking fine, which is $25 for the first hour or part of an hour that the car is parked illegally, plus $10 for every additional hour or part of an hour that the car is illegally parked. The toStringmethod should invoke the toStringmethods of the car and officer fields, and output the fine’s details.

 

ParkingTicket

-  car : ParkedCar

-  officer : PoliceOfficer

-  fine : double

-  minutes : int

+ BASE_FINE : double = 25.0

+ HOURLY_FINE : double = 10.0

+ ParkingTicket(aCar : ParkedCar, anOfficer : PoliceOfficer, meterMins : int)

+ ParkingTicket(ticket : ParkingTicket)

+ calculateFine() : void

 

setter and getter methods, and the toString method, not shown

 

In addition to writing the four classes, write a single class, PatrolSimulation, with a main routine that demonstrates the use of the four classes. The pseudocode for the main routine is shown in the below box.

 

// Create an array of 2 Car objects, with various minutesParked // values

// Create an array of 2 ParkingMeter objects, with minutes so that

// the first Car object is in violation, while the second is not

 

// Create an array of 2 ParkingTicket objects

// Create a PoliceOfficer object. Give the officer a name and badge

// number

// Have the officer patrol each of the Car and ParkingMeter object

// combinations (index i for the array of Car objects should be

// matched with index i for the array of ParkingMeter objects, which

// should be matched with index i of the array of ParkingTicket // objects)

// After the PoliceOfficer has patrolled the cars and parking

// meters, walk over the array of ParkingTickets and invoke the

// toString method if a ticket has been issued, otherwise indicate // that a ticket has not been issued

 

 

 

 

 

 

 

 

 

 

 

 

Refer to the rubric posted on the course website for details about point accrual. A sample invocation of the program is shown below.

 

Car/Parking Meter 1:

Car Data

Make: Volkswagen

Model: 1972

Color: Red

License Number: 147RHZM

Minutes Parked: 121

 

Officer Data:

Name: Joe Friday

BadgeNumber: 4788

 

Ticket Data

Minutes Illegally Parked: 61

Fine: $35.00

 

Car/Parking Meter 2:

No violation

 

 

Programming Task 2

                

Complete the fifth programming challenge, Password Verifier, on page 615 of the textbook. The UML diagram of the class is shown below.

 

PasswordVerifier

- MIN_PASSWORD_LENGTH : int = 6

+ isValid (str : String) : boolean

-    hasUpperCase(str : String) : boolean

-    hasLowerCase(srr : String) : boolean

-    hasDigit(str : String) : boolean

 

Write a class, PasswordVerifier, per the UML diagram above, and create a second class,

PasswordDemo, with a main routine to demonstrate the use of the PasswordVerifierclass.

The method isValidshould be static. Do NOT instantiate an object of type PasswordVerifier. You can have your program interact with the user via the command-line input, or by using dialogue boxes. The below two images show a (successful) invocation of the program PasswordDemo.

 

 

 

 

 

A sample invocation of the program is shown below.

 

 

Attachments:

Answers

(5)
Status NEW Posted 14 Nov 2017 07:11 AM My Price 10.00

-----------  ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly

Not Rated(0)