public class Room extends java.lang.Object implements java.io.Serializable {
public String description;
public Map<String, Room> map;
public List<Thing> things;
//Room
//Parameters:
//desc - Description for the room Note: any newlines in desc will be
replaced with *
public Room(java.lang.String desc){
this.description = desc;
}
//getDescription
//A description of the room
//Returns:
//Description
public java.lang.String getDescription(){
return description;
}
//replaceLine
//any new line in s will be replaced with *
public String replaceLine(String s){
return s.replace("\n", "*");
}
//setDescription
//Change Room description Note: any newlines in s will be
//replaced with *
//Parameters:
//s - new Description
public void setDescription(java.lang.String s){
this.description = replaceLine(s);
}
}
I am trying to write a Junit test for the last method:
@Test
public void setDescription(java.lang.String s) {
String input = "abc\n";
String expected = "abc";
setDescription(input);
assertEquals(expected, input);
}
I know that it is not correct but I have no idea how to fix it. I am pretty new to Java and coding as a whole. Could someone please help me with this?