Question: /** A class to test the Door class. */ public class DoorTester { /** Tests the methods of the Door class @param args not used
/**
A class to test the Door class.
*/
public class DoorTester
{ /**
Tests the methods of the Door class
@param args not used
*/
public static void main(String[] args)
{ Door frontDoor = new Door("Front", "open"); System.out.println("The front door is " + frontDoor.getState()); System.out.println("Expected: open"); Door backDoor = new Door("Back", "closed"); System.out.println("The back door is " + backDoor.getState()); System.out.println("Expected: closed"); // Use the mutator to change the state variable
backDoor.setState("open"); System.out.println("The back door is " + backDoor.getState()); System.out.println("Expected: open"); // Use the mutator to change the name variable
backDoor.setName("Kitchen"); System.out.println("The back door is called " + backDoor.getName()); System.out.println("Expected: Kitchen"); Door sideDoor = new Door("Side", "closed"); System.out.println("The side door is " + sideDoor.getState()); System.out.println("Expected: closed"); sideDoor.setState("open"); System.out.println("The side door is " + sideDoor.getState()); System.out.println("Expected: open"); }
}
1.8) Consider the variable state in the class Door and the variable newState in the mutator for state. What kind of variable is state? What kind of variable is newState? When do these variables exist?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
