Original Code: https://cgi.cse.unsw.edu.au/~cs1511/22T2/activities/cs_hotel/cs_hotel.c

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Original Code: https://cgi.cse.unsw.edu.au/~cs1511/22T2/activities/cs_hotel/cs_hotel.c

Post by answerhappygod »

OriginalCode: https://cgi.cse.unsw.edu.au/~cs1511/22T ... cs_hotel.c
Original Code Https Cgi Cse Unsw Edu Au Cs1511 22t2 Activities Cs Hotel Cs Hotel C 1
Original Code Https Cgi Cse Unsw Edu Au Cs1511 22t2 Activities Cs Hotel Cs Hotel C 1 (99.72 KiB) Viewed 71 times
Stage 1.1: Game Setup In stage 1.1, we will scan in all the current guests and add them to our hotel. Command Welcome to the CS Hotel!! Add your current guests, how many guests? [num guests] Input in your guests room numbers [floor_number] [room_on_floor] ... [num pieces times] ... [floor_number] [room_on_floor] Overview CS Hotel operates in 2 processes: the setup process and command process. Stage 1.1 will see you implement the setup process. Please ensure you are familiar with the starter code, as it contains the basis for this task (and the whole assignment). The program should: 1. Ask how many current guests there are. 2. Scan in the number of guests, n 3. Read in n number of [floor_number] [room_on_floor] sets. o If the input is invalid, print out the relevant error message (see below). o Otherwise, add the guest's booking ID to their room in the hotel 2D array. booking_id s should start at 0, and increase by 1 for every valid guest. 4. Print out the hotel (which has been done for you). Error Messages • If [floor_number] or [room_on_floor] is out of bounds for the 8x8 hotel, then the error Invalid room number! should be printed. • If the room is already occupied, then the error Room already occupied! should be printed.
Example 1.1.1: Scanning in Guests $ ./cs_hotel Welcome to the CS Hotel!! Add your current guests, how many guests? 4 Input in your guests room numbers 12 05 45 21 سال / --^--\ | 0 | | | |00| |--+- | |03| PALT |01| | |02| /^^^\ _|_"_|_ -+-· -+- Enter a command: Bye!
Stage 1.2: Printing the Stage Map If you have reached this point then you have finished implementing the game setup step. From this stage onwards the game is in the command step. This means that commands should be read in a loop until the user presses CTRL + D on the keyboard. Command Р Overview This stage will provide an ability for you to see the hotel from a side view, which shows which booking ids are in which rooms. When the p command is executed, your program should call the provided print_hotel function. HINT: Similarly to assignment 0, make sure to put a space before the %c when using the scanf function to avoid scanf from scanning in whitespace characters.
Example 1.2.1: Printing out the Hotel $ ./cs_hotel Welcome to the CS Hotel!! Add your current guests, how many guests? 4 Input in your guests room numbers 12 05 45 21 À / --^--\ | 0 | |03| ||00| -+--+-- | | |01| | -+--+--| -+-+-+ +--+- ا | | | ---+--| |02| | | | | -+--+--| /^^^\ _|_"_|___________ Enter a command: p
/ --^--\ | 0 | |00| | |03| اس |01| |02| | | /۸۸۸۱ _|_"_|_ | | -+-- | | | | Enter a command: [Ctrl-D] Bye!
Stage 1.3: Who is staying in that room? Command ? [floor] [room_on_floor] Overview This command allows us to ask who is in a certain room of the hotel. • If the input is invalid, then the relevant error message should be printed. • Otherwise, if the input is valid and the room is occupied, then the program should print Booking ID at Floor [floor], Room [room_on_floor] is : [booking_id] • Otherwise, if the input is valid and the room is empty, then the program should print Floor [floor], Room [room_on_floor] is empty. Error Messages • If [floor_number] or room_on_floor is out of bounds for the 8x8 hotel. Then the error Invalid room number! should be printed.
Example 1.3.1: Displaying booking IDs for rooms $ ./cs_hotel Welcome to the CS Hotel!! Add your current guests, how many guests? 4 Input in your guests room numbers 12 05 4 5 21 |--+--+- / --^--\ | 0 | | |00| | |03| |-- | |01| |02| /^^^\ _|_"_|. ا Enter a command: ? 4 5 Booking ID at Floor 4, Room 5 is : 2 Enter a command: ? 1 2 Booking ID at Floor 1, Room 2 is: 0 Enter a command: ? 4 4 Floor 4, Room 4 is empty.
Stage 1.4: Adding new guests! Command a [floor] [room_on_floor] Overview This command allows us to add more guests to our hotel! This should feel quite similar to some code written in stage 1.1. Your program should: • If the input is invalid, print out the relevant error message. • Otherwise, find the next available booking_id and add the guest's booking ID to their room in the hotel 2D array. ( booking_id s should start at 0, and increase by 1 for every valid guest). It should then print out: Guest's booking id is: [booking_id] HINT: You may want to think about extracting code from stage 1.1 into a function that you can use here. Error Messages If [floor_number] or room_on_floor is out of bounds for the 8x8 hotel, then the error Invalid room number! should be printed. • If the room is already occupied, then the error Room already occupied! should be printed.
Example 1.4.1: Adding more guests $ ./cs_hotel Welcome to the CS Hotel!! Add your current guests, how many guests? 3 Input in your guests room numbers 12 05 45 / --^-- \ | 0 | /_ _^_____^_\\ آسا | |01| | ||00| | | --+--+-- +--| /^^^\ _____|_"_|. -+-- | |02| | -+-- ---| | | +--+--+--+- Enter a command: a 0 0 Guest's booking id is: 3 Enter a command: p
|03| / --^--\ | 0 | /_ _^_____^_\\ | |01| | | -+--+--+--+--| | |00| | ||| آنا | | -+-- | |02| | | /^^^\ | | --+--+--+- _|_"_|_—________________ Enter a command: a 0 1 Guest's booking id is: 4 Enter a command: p
/ --^--\ | 0 | | --+- |03|04| | | 00 با ساله |01| 02 /۸۸۸۱ _|_"_|___________ Enter a command: [Ctrl-D] Bye!
Stage 1.5: Guests leaving the Hotel. Command 1 [floor] [room_on_floor] Overview This command gives us the ability to update the hotel when a guest leaves. • If the input is invalid, print out the relevant error message. • Otherwise, your program should set the booking ID of the given room back to -1 to represent NO_BOOKING and print out: Goodbye booking [booking_id]! Error Messages • If [floor_number] or Invalid room number! should be printed. • If the room is already empty, then the error This room is already empty. should be printed. room_on_floor is out of bounds for the 8x8 hotel, then the error
$ ./cs_hotel Welcome to the CS Hotel!! Example 1.5.1: Guests leaving Add your current guests, how many guests? 3 Input in your guests room numbers. 1 2 05 45 1 / --^--\ | 0 | __^___ |00| | |01| | |02| /^^^\ _|_"_|_ Enter a command: 1 1 2 Goodbye booking 0! Enter a command: p
/ --^--\ | 0 | / ^_^\ آسا | |01| | | -+--+--| ||| 1 /۸۸۸۱ ___________|_"_ | _—__—_—_—_—_—_ I | | -+-- | |02| | | ---+--+· | |
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply