Question: I am writing a class in Java that has to do with the number of marbles in a jar. Within this class I have methods
I am writing a class in Java that has to do with the number of marbles in a jar. Within this class I have methods where you can add and subtract the number of marbles in the jar. For example:
public void add(int marbles){
this.marbles += marbles;
}
I am trying to figure out how to finish the following method so that I can it can turn 'on' the add/subtract methods when the boolean is true and 'off' when the boolean is false:
public static void mutateJar(boolean change){
}
I can edit the add and subtract methods and I can also make new helper methods to make the method above work. Can anyone help with this? Thanks!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
