Question: In Java: 5) Consider a class ParkingMeter that models a coin-operated parking meter. We will assume it only takes quarters. Its public interface includes: A

In Java:

 In Java: 5) Consider a class ParkingMeter that models a coin-operatedparking meter. We will assume it only takes quarters. Its public interface

5) Consider a class ParkingMeter that models a coin-operated parking meter. We will assume it only takes quarters. Its public interface includes: A method insertcoin(int howMany) that simulates adding the given number of quarters. Inserting coins increases the time remaining on the meter, but not more than the maximum time. A method getTimeRemaining () that returns the time remaining on the meter in minutes as an int value. A method passTime (int minutes) that simulates the passage of time, that is, reduces the time remaining (but not below zero) A method getTotal () that returns the total amount of money, in dollars, collected by this meter. A constructor ParkingMeter (int minutesPerQuarter, int maximumTime), where minutesPerQuarter is the number of minutes you get for a quarter, and maximumtime is the maximum number of minutes. A newly created ParkingMeter has no time on it. a) Write a class MeterTest with a main method that tests the ParkingMeter class above under the following scenario: A new parking meter is constructed with 15 minutes per quarter and a maximum of 60 minutes Three quarters are inserted 20 minutes passes Four quarters are inserted 90 minutes passes Activa At the points marked (*), your test should check the values returned by the accessor methods. Print out the actual value obtained from calling the method, and then print out the correct value that you expect; no other output is required. b) Write a complete implementation of the ParkingMeter class described above 5) Consider a class ParkingMeter that models a coin-operated parking meter. We will assume it only takes quarters. Its public interface includes: A method insertcoin(int howMany) that simulates adding the given number of quarters. Inserting coins increases the time remaining on the meter, but not more than the maximum time. A method getTimeRemaining () that returns the time remaining on the meter in minutes as an int value. A method passTime (int minutes) that simulates the passage of time, that is, reduces the time remaining (but not below zero) A method getTotal () that returns the total amount of money, in dollars, collected by this meter. A constructor ParkingMeter (int minutesPerQuarter, int maximumTime), where minutesPerQuarter is the number of minutes you get for a quarter, and maximumtime is the maximum number of minutes. A newly created ParkingMeter has no time on it. a) Write a class MeterTest with a main method that tests the ParkingMeter class above under the following scenario: A new parking meter is constructed with 15 minutes per quarter and a maximum of 60 minutes Three quarters are inserted 20 minutes passes Four quarters are inserted 90 minutes passes Activa At the points marked (*), your test should check the values returned by the accessor methods. Print out the actual value obtained from calling the method, and then print out the correct value that you expect; no other output is required. b) Write a complete implementation of the ParkingMeter class described above

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!