This repository has been archived on 2026-10-15. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
projectstem-keys-java/Hotel Room/Part B/Room.java
T
2024-03-11 12:33:03 -07:00

48 lines
1.2 KiB
Java

/* COMPLETE WORKING CLASS PROVIDED */
/* DO NOT MODIFY THE IMPLEMENTATION OF THIS CLASS*/
public class Room
{
private int roomNumber;
private boolean occupied;
private String bookingName;
/** Attempts to check a new guest into the room. If the room is not occupied (the
* variable occupied is false), changes bookingName to name and sets
* occupied to true.
* Otherwise does not change the values of the member variables.
* @param name the name of the guest checking in as a String
* @return true if the check-in was successful and bookingName was changed
* false otherwise
*/
public boolean checkInNewGuest(String name)
{
if(occupied) return false;
bookingName = name;
occupied = true;
return true;
}
/** @return the room number
*/
public int getNumber()
{ return roomNumber; }
/** @return true if the room is occupied; false otherwise.
*/
public boolean isOccupied()
{ return occupied; }
public Room (int rn, boolean o, String bn){
roomNumber = rn;
occupied = o;
bookingName = bn;
}
public String toString(){
return roomNumber+"; "+occupied+"; "+bookingName;
}
}