I'm making a few assumptions before doing this. They are:
1. The rooms are stored in an array.
2. The rooms are stored as Room objects.
3. getOccupier returns a String
public int findVacantRoom(){
for(int i = 0; i < rooms.length; i++){
if (rooms[i].getOccupier() == null){
return i;
}
}
return -1;
}
Essentially what this does is checks all of the rooms in the room array starting at zero. When a vacant room is encountered, the array index of that room is returned. (You might have to return something like rooms[i].roomNumber if the room numbers do not correspond to the array index.) If the for loop completes without finding a vacant room, -1 is returned.
Again, if my assumptions aren't true than this might not work. Regardless of how the data is stored, the idea is the same though.
Good luck.