I have a State class with these fields
String name;
City capital;
ArrayList<String> neighbors;
I have a toString() method
public String toString(){
return ("new State(" +
this.name + ", " +
this.capital + ", " +
this.neighbors + ")\n");
}
I am trying to test this method on the state
State ME = new State("ME", augusta, MEneighbors );
Where augusta is a defined City, and MEneighbors is an ArrayList with
MEneighbors.add("NH");
This is my test so far
t.checkExpect(ME.toString(),
"new State(ME, " + augusta.toString() + ", " + [NH] + ")");
I don't quite understand why this isn't working. It works until the ArrayList MEneighbors. How can I get it to add the ArrayList as a String?
Many thanks.
+ [NH] +This will never compile in this world.