im struggling with abit of java code.
Currently i have 8 rooms
room1 = new Room(1,1);
room2 = new Room(2,1);
room3 = new Room(3,1);
room4 = new Room(4,1);
room5 = new Room(5,2);
room6 = new Room(6,2);
room7 = new Room(7,3);
room8 = new Room(8,3);
Now i need to make it so that the user inputs a number 1 to 8 regarding the room they require, then the system needs to add that number to the prefix room so that i can call methods of the desired room.
I currently have this code to receive the selection
roomselect = scan.nextInt();
and then this is where i get stuck as im unsure how to add roomselect integer onto the prefix ‘room’
thanks
Just use arrays:
So, to solve your case: