1) Through BlueJ, write if the current number of shoppers is greater than or equal to the number leaving then the number of shoppers is decreased by the number leaving. Otherwise, the following error message must be printed and the number of shoppers present must be set to 0. There is an error in the number of shoppers. Use System.out.println to print the message. 2) The class must define a method called leaving that takes a single integer parameter. This represents the number of shoppers leaving the club at a particular point. You may assume that the parameter's value will always be greater than zero and you do not have to check for that. If the current number of clubbers is greater than or equal to the number leaving then the number of clubbers is decreased by the number leaving. Otherwise, the following error message must be printed and the number of clubbers present must be set to 0. There is an error in the number of shoppers. Use System.out.println to print the error message. 3) The class must define a method called is Space that allows the night club staff to determine whether there is enough capacity for a group to attend. This method must take a single integer parameter representing the size of the group, and return a boolean result. The method must work as follows: If the value of the parameter is less-than or equal-to 0 then the method must return false. This case has priority over those following. If the value of the parameter is less-than or equal-to the space left in the night club (use the capacity and occupancy values in the to work this out) then the method must return true. Otherwise (i.e., if there is not space in the night club for the whole group) then the method must return false. (Note that the method must only return true if there is space for the whole group to attend. This method must not change the state of the BookClub object. In other words, both the current number of occupants and the capacity of the club must be exactly the same after it is called as it was before.)
1) Through BlueJ, write if the current number of shoppers is greater than or equal to the number leaving then the number of shoppers is decreased by the number leaving. Otherwise, the following error message must be printed and the number of shoppers present must be set to 0. There is an error in the number of shoppers. Use System.out.println to print the message.
2) The class must define a method called leaving that takes a single integer parameter. This represents the number of shoppers leaving the club at a particular point. You may assume that the parameter's value will always be greater than zero and you do not have to check for that. If the current number of clubbers is greater than or equal to the number leaving then the number of clubbers is decreased by the number leaving. Otherwise, the following error message must be printed and the number of clubbers present must be set to 0. There is an error in the number of shoppers. Use System.out.println to print the error message.
3) The class must define a method called is Space that allows the night club staff to determine whether there is enough capacity for a group to attend. This method must take a single integer parameter representing the size of the group, and return a boolean result. The method must work as follows: If the value of the parameter is less-than or equal-to 0 then the method must return false. This case has priority over those following. If the value of the parameter is less-than or equal-to the space left in the night club (use the capacity and occupancy values in the to work this out) then the method must return true. Otherwise (i.e., if there is not space in the night club for the whole group) then the method must return false. (Note that the method must only return true if there is space for the whole group to attend. This method must not change the state of the BookClub object. In other words, both the current number of occupants and the capacity of the club must be exactly the same after it is called as it was before.)
Step by step
Solved in 5 steps with 3 images