Hello, so i have a RectangularRoom, AbstractRoom (which is an abstract class) and Room (which is an interface). AbstractRoom and RectangularRoom both implement Room. Within my HomeCADengine (which is where my addRoom/removeRoom/etc. methods are kept). Now, my addRoom method seems to be a problem. I am trying to add a room to my ArrayList within this method, but cannot because Room is an interface, it says it can not be instantiated, and so can not add the room to the ArrayList. How can i add a room to my ArrayList?
public void addRoom(Room room){
List<Room> rooms = new ArrayList<Room>();
RoomReference ref;
String name;
int x, y, z;
rooms.add(new Room(ref, name, x, y, z));
}
Error message:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
Cannot instantiate the type Room
at homecad.model.facade.HomeCADengine.addRoom(HomeCADengine.java:31)
at homecad.test.TestHarness.testAddRoom(TestHarness.java:105)
ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return code = -2
JDWP exit error AGENT_ERROR_NO_JNI_ENV(183): [../../../src/share/back/util.c:820]
Line 31: rooms.add(new Room(ref, name, x, y, z));
Line 105: model.addRoom(new RectangularRoom(ref1, "RoomA", 3, 4, 2));
Thanks in advance.