public class House extends Device {
static final int ADD = 'a';
static final int SHOW = 's';
static final int ONOFF = 'o';
static final int QUIT = 'q';
public void main() {
Scanner in = new Scanner(System.in);
Device theDevice = new Device();
while (true) {
System.out.print("(a)dd, (s)how, (o)n/off, (q)uit: ");
char input = in.next().toLowerCase().charAt(0);
if (input == ADD) {
System.out.print("Device name: ");
String deviceName = in.nextLine();
theDevice.addDevice(deviceName);
}
}
}
}
class Device {
List<String> deviceName = new ArrayList<String>();
List<Boolean> deviceStatus = new ArrayList<Boolean>();
List<Long> deviceOnTime = new ArrayList<Long>();
void addDevice(String deviceName) {
this.deviceName.add(deviceName);
this.deviceStatus.add(false);
this.deviceOnTime.add(0L);
}
}
I put my code like this and when executed it was shown like this
(a)dd, (s)how, (o)n/off, (q)uit: a Device name: (a)dd, (s)how, (o)n/off, (q)uit:
it's not waiting for me to input something like it suppose to be. How can I fix it.
Thx a lot.