Question: Assignment summary: You will write a program to keep track of reservations at Anteater Inn, a small inn. Statement of the problem: UCI has just

Assignment summary: You will write a program to keep track of reservations at "Anteater Inn", a small inn.

Statement of the problem: UCI has just started a program in hotel and restaurant management; its dean has established a small inn as a lab for the program's students. The dean has asked you to write the reservations software for this new inn. Your program will be called AnIn.

Your program will keep track of the rooms available for rent (these vary, since sometimes a room is closed for redecoration) and the reservations that guests have made for these rooms.

When the full AnIn system is completed, it might have a graphical user interface, but for now your program will be a batch program; this means that you will supply one input file that contains all the commands and one output file that will contain all your output. Include these two lines in your code:

infile = open('INNcommands.txt', 'r') outfile = open('INNresults.txt', 'w')

The automated checking depends on your using precisely those file names.

You could easily convert this program to an interactive one with a fancy user interface, where the program presents the user with a menu of commands, accepts the user's selection, prompts the user for whatever additional information the command requires, and then displays the results of that command. We made this assignment a batch program for three reasons: First, it's extra work for you to write the menu-printing and input-prompting commands, some of which you have already done in other assignments. It's easier simply to assume that the data appears in the correct format in the input files. Second, it gives you more practice reading data from external text files. Third, testing your program will be much easier when you can create files of test data rather than typing in each test interactively every time.

The input for this program comes from a single text file named

INNcommands.txt, which consists of an unlimited number of input command lines. You will create this file based on expected input described below. For each stage, you will implement (or modify) a few more commands.

Stage 1: For this stage, your program will keep track of the rooms that are available. This stage implements four commands, as described below. On each command line, the first four non-whitespace characters are the command; command letters may be upper or lower case.

ANBR

(for "add a new bedroom") followed by an integer room number (in the range 1999). Add a new bedroom with the specified room number.

LABR

(for "list of available bedrooms"). Print a list of the bedrooms currently available. The input file may contain any number of these commands in any order; each LABR command prints a list of available bedrooms based on what has been added as of that point. See the sample output below for the format of the printed bedroom list. For this stage, it doesn't matter what order the bedrooms appear in.

PNTL

(for "print line"), followed by any text. Simply print (or "echo") a line, copying the input (not counting the PNTL and leading whitespace) to the output. You'll find it useful in testing, and it's also a simple way to make the program's reports clearer or fancier.

**

Comment, followed by any text. Like comments in a program, comment lines don't have any effect on the program's behavior; they just serve as annotations in the command file.

Below is a sample input file for this stage.

** This is a sample command file for the AnIn, Stage 1 PNTL *********************************************************** PNTL Here is a list of available bedrooms (before adding any!) ** A well-written program works gracefully with empty lists. LABR PNTL *********************************************************** ** Now let's add a bedroom: ANBR 101 LABR ** And some more: ANBR 104 ** Extra blanks around the command should be ignored ANbr 102 ANBr 201 aNbr 203 LABR PnTL Thank you for perusing the Anteater Inn Reservation System! ** That's the end of the sample data for Stage 1. 

From this input file, your program should produce the following output:

*********************************************************** Here is a list of available bedrooms (before adding any!) Number of bedrooms in service: 0 ------------------------------------ *********************************************************** Number of bedrooms in service: 1 ------------------------------------ 101 Number of bedrooms in service: 5 ------------------------------------ 101 104 102 201 203 Thank you for perusing the Anteater Inn Reservation System!

One of the early questions to ask when designing a program is what data structure(s) you should use to represent the main information in the program. Making decisions like this becomes easier with practice, but there are two things to keep in mind. First, start with the simplest data structure that does the job. (For the collection of bedrooms in this stage, maybe a list of integer room numbers is good enough, or maybe a set of room numbers.) Second, accept that your first choice may not be your final choice; as the specifications become clearer or as circumstances change (or as you get to later stages in a problem like this one), you may decide that something else would work better. This kind of revision is a normal part of programming. It's no tragedy to rewrite some code in a better way, just as you should expect to revise natural-language documents. (For the bedrooms in this problem, we might decide to use a dictionary whose key is the room number and whose value is a namedtuple of room information. But we shouldn't necessarily jump to this arrangement until we're sure it helps us.)

(f) Read over the first stage of "Anteater Inn" problem. This will be a large part of Lab Assignment 9; it will be helpful for you to get a head start by reading the specification and learning what it's all about.

Then write and submit a solution to Stage 1 of the AnIn problem, in a file called AnIn1.py.

For Stage 1 in this assignment, the "main function" in your code should be named anin; it should take no arguments, it should prompt the user (using input()) for the name of the command file, and it should print its results (to the normal place, the console). The last line of your AnIn1.py file should be a call to anin(); that will start things up.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!