Advertisement
Guest User

ExitMachine

a guest
Sep 27th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.01 KB | None | 0 0
  1. public class ExitMachine {
  2.  
  3.    
  4.     private int numPeopleExited;
  5.    
  6.     // Constructor
  7.    
  8.     public ExitMachine(SimpleClock givenClock) {
  9.     }
  10.    
  11.     // Methods
  12.    
  13.     /*
  14.      * Simulates inserting a ticket into the machine.
  15.      * If the ticket's payment time is within ParkingRateUtil.EXIT_TIME_LIMIT minutes of this machine's clock time, the method returns true.
  16.      * Ticket object is not modified. If the method returns true, the machine's exit count is incremented.
  17.      */
  18.     public boolean insertTicket(Ticket t) {
  19.         if (t.getPaymentTime() <= ParkingRateUtil.EXIT_TIME_LIMIT) {
  20.             return true;
  21.         }
  22.         else {
  23.             return false;
  24.         }
  25.     }
  26.    
  27.     /*
  28.      * Counts the number of people who exited.
  29.      * Adds 1 if insertTicket returns true.
  30.      */
  31.     public void Counter() {
  32.             numPeopleExited = numPeopleExited + 1;
  33.     }
  34.    
  35.     /*
  36.      * Returns a count of the total number of successful exits.
  37.      * A "successful exit" is defined to be a call to insertTicket() that returns true.
  38.      */
  39.     public int getExitCount() {
  40.         return numPeopleExited;
  41.        
  42.         }
  43.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement