Answer:
Flip.java 
 
public class Flip { 
 
 // private attribute indicating state 
 
 private boolean state; 
 
 // constructor taking initial boolean value for the state 
 
 public Flip(boolean state) { 
 
 this.state = state; 
 
 } 
 
 // method to switch the state and return new state 
 
 public boolean flop() { 
 
 // changing state to false if it is true, true if it is false 
 
 state = !state; 
 
 // returning the new state 
 
 return state; 
 
 } 
 
 // main method containing code for testing. remove if you don't need this 
 
 public static void main(String[] args) { 
 
 Flip flip = new Flip(true); 
 
 System.out.println(flip.flop()); // false 
 
 System.out.println(flip.flop()); // true 
 
 System.out.println(flip.flop()); // false 
 
 Flip flop = new Flip(false); 
 
 System.out.println(flop.flop()); // true 
 
 System.out.println(flop.flop()); // false 
 
 System.out.println(flop.flop()); // true 
 
 } 
 
}
Step-by-step explanation: