Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ExitMachine {
- private int numPeopleExited;
- // Constructor
- public ExitMachine(SimpleClock givenClock) {
- }
- // Methods
- /*
- * Simulates inserting a ticket into the machine.
- * If the ticket's payment time is within ParkingRateUtil.EXIT_TIME_LIMIT minutes of this machine's clock time, the method returns true.
- * Ticket object is not modified. If the method returns true, the machine's exit count is incremented.
- */
- public boolean insertTicket(Ticket t) {
- if (t.getPaymentTime() <= ParkingRateUtil.EXIT_TIME_LIMIT) {
- return true;
- }
- else {
- return false;
- }
- }
- /*
- * Counts the number of people who exited.
- * Adds 1 if insertTicket returns true.
- */
- public void Counter() {
- numPeopleExited = numPeopleExited + 1;
- }
- /*
- * Returns a count of the total number of successful exits.
- * A "successful exit" is defined to be a call to insertTicket() that returns true.
- */
- public int getExitCount() {
- return numPeopleExited;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement