On the left above is the UML class diagram for the InnRoom class. On the right i
ID: 3683580 • Letter: O
Question
On the left above is the UML class diagram for the InnRoom class. On the right is the diagram for the InnRoom class you need. Notice the differences between the two classes. Make a new project and create an InnRoom.java class that matches the diagram on the right. If it helps, copy your InnRoom code from last week’s project and modify that.
This is what I have for the InnRoom on the left:
public class InnRoom {
private String interestingObject;
private int roomNumber;
// Contructor
public InnRoom (int rNum){
roomNumber = rNum;
}
public String getInterestingObject(){
return interestingObject;
}
public void setInterestingObject(String Object){
interestingObject = Object;
}
public int getRoomNumber(){
return roomNumber;
}
public void displayRoomDescription(){
System.out.println("In room " +roomNumber + " you see a " +interestingObject);
}
}
If you haven’t put any code into the displayRoomDescription method yet, here’s a hint: That method doesn’t take any parameters, and it doesn’t return anything, but it should have some code in it that writes output to the console (like calls to System.out.println). You can make the room description work however you like, but it should probably use the interestingObject. One way you could do this, would be to have the following line in displayRoomDescription: System.out.println(“In this room you see ” + interestingObject); InnRoom CInnRoom What changes do you have to make to InnRoom.java to get to the class described in the a interestingObject: String a roomNumber: int a interestingObject: String InnRoom(int) InnRoom() getinterestingobjeStringsetlnterestingObject(String)voiddiagram on the right? getinterestingObjectO:String o setinterestingObject(String):void getlnterestingObject():String o getRoomNumberO:int O displayRoomDescription0:voiddisplayRoomDescription():voidExplanation / Answer
public class InnRoom {
private String interestingObject;
/**
* default constructor
*/
public InnRoom() {
// TODO Auto-generated constructor stub
interestingObject = "";
}
/**
* @return the interestingObject
*/
public String getInterestingObject() {
return interestingObject;
}
/**
* @param interestingObject
* the interestingObject to set
*/
public void setInterestingObject(String interestingObject) {
this.interestingObject = interestingObject;
}
/**
*
*/
public void displayRoomDescription() {
System.out.println("In this room you see " + interestingObject);
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.