Question: Need create a Room class contained within a Room.java file (this means that your project will now contain two .java source files: Main.java and Room.java).

Need create a Room class contained within a Room.java file (this means that your project will now contain two .java source files: Main.java and Room.java). An instance of the Room class represents a single room within the house. Presently, each room has only a single attribute: its name (i.e. Foyer or Kitchen). Within the Room class, create a private (non-static) class member variable called name of type String. Expose this class member variable through public (non-static) getter and setter methods named, getName() and setName(), respectively. Create a public Room constructor which accepts a String parameter called name. Within the body of the constructor, invoke the setName method to initialize the corresponding data member. In your Main class, replace the rooms variable type from a 3x3 array of String objects to a 3x3 array of Room objects. Keep the same floor plan as before and pass the name of each Room to the class constructor as you instantiate each object in the array. Change the code that displays the name of the current room to employ the getName() method of the Room class.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!