Question: Everything in Stage I goes into BandBV.py Take a command line argument which is the filename, which is the command script, in your main statement.
Everything in Stage I goes into BandBV.py
Take a command line argument which is the filename, which is the command script, in your main statement. Do NOT take input! Read the file with the given filename.
Create a function called anteaterbnb which takes one input argument which is a string representing command script
Process the string linebyline Hint: split by newline character
Create a variable in modular scope named "bedrooms", with appropriate data structure, to record bedroom numbers
Create a function commandlb which takes in one single line of command a string starting with LB and process accordingly
Create a function commandpl which takes in one single line of command a string starting with PL and process accordingly
Create a function commandnb which takes in one single line of command a string starting with NB and process accordingly
In anteaterbnb call one of the command functions whenever a newline in command script is stepped onto
Add functions for other commands as needed in each stage
Don't be afraid to think outside the box
Hints and Suggestions
It is recommended to program this assignment using debugging tools found in Python Tutor or in your favorite IDE such as IDLE, PyCharm, Visual Studio and etc. These tools help you debug and refactor your program. ZyBooks is not intended for larger scale inbrowser Python development, but you of course are welcome to just use ZyBooks.
One of the early questions to ask when designing a program is what data structures 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 naturallanguage 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 but it isn't a bad ideau
Don't give up The lab is long, but if you follow the hints, use good data structures, break things down step by step, and think ahead it is not difficult!
Stage I
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 two nonwhitespace characters are the command; command letters may be upper or lower case.
NB for "add a new bedroom" followed by an integer room number in the range u Add a new bedroom with the specified room number.
LB for "list bedrooms" Print a list of the bedrooms currently available. The input file may contain any number of these commands in any order; each LB 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
PL for "print line" followed by any text. Simply print or "echo" a line, copying the input not counting the PL 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 command script for this stage.
This is a sample command file for the Anteater BandB, Stage I
PL
PL Here is a list of available bedrooms before adding any!
A wellwritten program works gracefully with empty lists.
LB
PL
Now let's add a bedroom:
NB
LB
And some more:
NB
Extra blanks around the command should be ignored
Nb
NB
Nb
LB
PL Thank you for using the Anteater BandB Reservation System!
That's the end of the sample data for Stage I.
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:
Number of bedrooms in service:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
