Hi guys Im having trouble creating an instance of a subclass:
package room;
public class Room {
String roomNumber;
int capacity;
boolean projection;
public Room(String rm, int n, boolean p) {
roomNumber = rm;
capacity = n;
projection = p;
}
public String getRoomNumber() {
return roomNumber;
}
public int getCapacity() {
return capacity;
}
public boolean hasProjector() {
return projection;
}
public class ComputerLab extends Room {
private String os;
public ComputerLab(String rm, int n, boolean p, String os) {
super(rm, n, p);
this.os = os;
}
public String getOS() {
return os;
}
public void setOS(String update) {
os = update;
}
}
public static void main(String[] args) {
Room r;
r = new ComputerLab("G102", 20, true, "WindowsXP");
System.out.println(r.getCapacity());
}
}
In the line where I create the ComputerLab object in my main function, i am getting the following error:
Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - non-static variable this cannot be referenced from a static context
at room.Room.main(Room.java:48)
Can anyone help explain why this error is occuring and how to fix it? Many thanks