Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Server {
- private final int id;
- private final boolean avail;
- private final boolean anyoneWaiting;
- private final double whenFree;
- Server(int identifier, boolean isAvailable, boolean hasWaitingCustomer, double nextAvailableTime){
- this.id = identifier;
- this.avail = isAvailable;
- this.anyoneWaiting = hasWaitingCustomer;
- this.whenFree = nextAvailableTime;
- }
- int servergiveID() {
- return id;
- }
- boolean giveAvail() {
- return avail;
- }
- boolean giveWaiting() {
- return anyoneWaiting;
- }
- double giveFree() {
- return whenFree;
- }
- public String toString() {
- if (avail) {
- return String.format("%d is available", id);
- } else if (anyoneWaiting) {
- return String.format("%d is busy; waiting customer to be served at %.3f", id, whenFree);
- } else {
- return String.format("%d is busy; available at %.3f", id, whenFree);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement