/** * 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 = new Die(); Die die2 = new Die(); die1.setFaceValue(2); die2.setFaceValue(3); if(die1 == die2){ System.out.println("Yes, the die are equal according to =="); } else{ System.out.println("No, the die are not equal according to =="); } boolean areTheSame = die1.equals(die2); if(areTheSame){ System.out.println("Yes, the die are equal according to the equals() method"); } else{ System.out.println("No, the die are not equal according to the equals() method"); } } }