/** * This class illustrates two methods for comparing objects: * 1. The == operator (and the != operator) tests for memory equality * 2. The equals() method tests for state equality * * @author alchambers * @version sp16 */ public class DieController { public static void main(String[] args){ // How can you modify this code to get all 4 possible print statements? // 1. yes and yes // 2. yes and no // 3. no and yes // 4. no and no // Die die1 = ... // Die die2 = ... // This checks if the die are equal using == if(die1 == die2){ System.out.println("Yes, they are equal according to =="); } else{ System.out.println("No, they are not equal according to =="); } // This checks if the die are equal using the equals() method boolean areTheSame = die1.equals(die2); if(areTheSame){ System.out.println("Yes, they are equal according to the equals() method"); } else{ System.out.println("No, they are not equal according to the equals() method"); } } }