I currently have a class Room and a class Hostel which holds rooms = new ArrayList < Room >();. I then have a BookRoomGUI class.
When a room is added to the arraylist it uses the following constructor:
public Room(int newRoomNo, boolean newRoomEnSuite)
{
roomNo = newRoomNo;
roomEnSuite = newRoomEnSuite;
roomBooking = "Free";
roomNights = 0;
roomBooker = "No Booker";
}
In the BookRoomGUI class i have the following JTextFields:
fields.add(roomnumberJTextField);
fields.add(bookerJtextField);
fields.add(nightsJTextField);
fields.add(peoplenoJTextField);
I am trying to make a method within Hostel which will take the values of these text fields and alter the corresponding variables in the original constructor if the room number matches:
public int makeBooking(int number)
{
for (Room room : rooms)
{
if (number == room.getRoomNo())
{
room.setRoomBooker(bookRoom.booker);
}
}
}
My question is what should go in the if statement? currently i use booker = bookerJtextField.getText(); to take the text from the text field in BookRoomGUI and setRoomBooker in Room but this does not work and i am presented with
setRoomBooker() in Room cannot be applied to (java.lang.String)
number -> Roommap instead of list. Make sure you havesetRoomBooker(String)method inRoomclass.