Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. package eksamen2017;
  2.  
  3. public class Table {
  4. int capacity;
  5. int tableNum;
  6. private static int counter = 0;
  7. /**
  8. * Initializes this Table with the provided capacity.
  9. * The table is also assigned a unique number.
  10. * @param capacity
  11. */
  12. public Table(int capacity) {
  13. this.capacity = capacity;
  14. counter++;
  15. this.tableNum = counter;
  16. }
  17.  
  18. /**
  19. * @return the table number
  20. */
  21. public int getNum() {
  22. return tableNum;
  23. }
  24. public int getCapacity() {
  25. return capacity;
  26. }
  27. }
  28.  
  29.  
  30. package eksamen2017;
  31.  
  32. public class Seating {
  33. Table table;
  34. Group group;
  35.  
  36. public Seating(Group group, Table table) {
  37. if(table.getCapacity() < group.getGroupSize() ) {
  38. throw new IllegalArgumentException("For mange gjester");
  39. }
  40. this.table = table;
  41. this.group = group;
  42. }
  43.  
  44. public Table getTable() {
  45. return table;
  46. }
  47.  
  48. public Group getGroup() {
  49. return group;
  50. }
  51.  
  52.  
  53. }
  54.  
  55.  
  56. package eksamen2017;
  57.  
  58. //part 1
  59.  
  60. /**
  61. * A group (of people) dining together, and should be seated at the same table.
  62. * We currently only need to handle the size.
  63. */
  64. public class Group {
  65.  
  66. int size;
  67. Seating seating;
  68.  
  69. public Group(int guestCount) {
  70. this.size = guestCount;
  71. }
  72. public int getGroupSize() {
  73. return size;
  74. }
  75. public void setSeating(Seating seating) {
  76. this.seating = seating;
  77. }
  78.  
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement