0

well hi guys new to the forum and i need some help

im writing a program where a guest’s name is entered and then assigned to a room. The motel has three floors and 30 rooms thus im using a 2D array (arr[3][10]) its supposed reserve a room and the room cannot be reserved again under a different name.

hope u can help
Tej

4
Contributors
4
Replies
5
Views
12 Years
Discussion Span
Last Post by NPH
0

Fill the correct spot when someone wants a room:

Someone wants room 20 on floor 5:

array[5][20] = "Persons name";

0

thanks for the new insight but i still have one other problem how do i stop a person from booking the same room again

-tej

0

To check if someone is already in the room use the following code:

boolean isRoomOccupied(int floor, int room)
{
   if( array[floor][room] == null )
      return true;
   else
      return false;
}

When someone checks out call this function

void checkOut(int floor, int room)
{
    array[floor][room] = null;
}

It is very important that you reset it back to null when it is check out time otherwise the first function won't work (because it checks for null)

For more help, www.NeedProgrammingHelp.com

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.