Advertisement
Guest User

Untitled

a guest
Sep 26th, 2020
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1.  
  2. class Server {
  3. private final int id;
  4. private final boolean avail;
  5. private final boolean anyoneWaiting;
  6. private final double whenFree;
  7.  
  8. Server(int identifier, boolean isAvailable, boolean hasWaitingCustomer, double nextAvailableTime){
  9. this.id = identifier;
  10. this.avail = isAvailable;
  11. this.anyoneWaiting = hasWaitingCustomer;
  12. this.whenFree = nextAvailableTime;
  13. }
  14.  
  15. int servergiveID() {
  16. return id;
  17. }
  18.  
  19. boolean giveAvail() {
  20. return avail;
  21. }
  22.  
  23. boolean giveWaiting() {
  24. return anyoneWaiting;
  25. }
  26.  
  27. double giveFree() {
  28. return whenFree;
  29. }
  30.  
  31. public String toString() {
  32. if (avail) {
  33. return String.format("%d is available", id);
  34. } else if (anyoneWaiting) {
  35. return String.format("%d is busy; waiting customer to be served at %.3f", id, whenFree);
  36. } else {
  37. return String.format("%d is busy; available at %.3f", id, whenFree);
  38. }
  39. }
  40. }
  41.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement