Q5
package model; // Represents a customer at a bank public class Customer { } package model; // Represents a teller working at a bank public class Teller { } package model; import java.util.LinkedList; // Represents a queue of customers at a bank public class CustomerQueue { public static final int MAX_LENGTH = 10; private LinkedList<Customer> queue; public CustomerQueue() { queue = new LinkedList<>(); } public boolean add(Customer c) { if (queue.size() < MAX_LENGTH) { queue.add(c); return true; } return false; } public Customer serve() { return queue.remove(); } public void clear() { queue.clear(); } public int size() { return queue.size(); } } package model; // Represents a customer service station at a bank public class Station { private Teller teller; private CustomerQueue queue; public Station() { teller = null; queue = new CustomerQueue(); } public void setTeller(Teller t) { this.teller = t; } public Teller getTeller() { return teller; } public CustomerQueue getQueue() { return queue; } }
public class Trip { public static final int COST = 125; //in cents // EFFECTS: constructs trip that starts at origin public Trip(String origin) { //stub } // EFFECTS: returns the name of the stop where this trip originated public String getOrigin() { return ""; //stub } } //A transit card with a balance that earns a reward of REWARD_AMOUNT cents //for every NUM_TRIPS_FOR_REWARD charged to the card. So if NUM_TRIPS_FOR_REWARD //is 5 and REWARD_AMOUNT is 10, the card earns a reward of 10 cents (which is //added to card's balance) for every 5th trip that is succefully charged to //the card public class TransitCard { public static final int NUM_TRIPS_FOR_REWARD = 5; public static final int REWARD_AMOUNT = 10; protected int balance; // EFFECTS: public TransitCard(int initBalance) { //stub } public int getBalance() { return 0; } public void reload(int amount) { } // MODIFIES: this // EFFECTS: if this card has sufficient balance to make a trip: // - deduces the cost of trip // - adds reward points to balance (if owing) // - returns true // otherwise returns false public boolean makeTrip(Trip trip) { return false; //stub } }
======================================