Overview
In this project you will create a program to simulate the job of a receptionist at a pet daycare and boarding facility. There will be several options to choose from, and different outputs depending on the selected option.
Objectives
The objective of this project is to create a solution combining multiple concepts that have been presented in class, building off of the concepts demonstrated in Project 1 with the addition of:
Note that you should only use techniques we have covered in class. Using more advanced concepts does not help your understanding of the basics, and is a red flag that the code may not be your own work. In particular, you may NOT use the Python break, quit, exit or any other programming convention to prematurely exit out of a loop or your program. A thorough understanding of loops requires that you are able to structure the loop control correctly without using break or other forced exit. Even though you may pass the test cases, use of any of these instructions will result in a 20% reduction in your your overall score. If you have questions about this as you work on your program, discuss it with your class assistants or with the course instructors.
Problem Description
This program is used to simulate the job of a receptionist at a pet daycare and boarding facility. The first task is to print a menu, displaying several possible actions. Each action is associated with a number, which is how the user will indicate their selection from the menu. There will be five different actions, each representing a task the receptionist can perform. These actions include: registering a new customer, checking in a pet, checking out a pet, displaying all of the registered customers, and logging out. The user should be able to select multiple actions within the same session until they choose to logout. Details are given below.
Printing the Menu
Before the selection of an action, the program must print out the menu.
Welcome to the best pet daycare ever!
Please select one of the following choices.
1. Register a new customer.
2. Check in a pet.
3. Check out a pet.
4. Display customers.
5. Logout.
If the selected option is not 1-5, the following error message must be displayed.
Invalid choice. Try again.
The user should be prompted with the menu again afterwards. In other words, you should print the "Please select one of the following choices" and the menu, but not the "Welcome" message again.
NOTE: Keep in mind that the menu will have to be printed out repeatedly after each action is completed until the user chooses the option to logout. Also note that you need to think about what is printed vs what is a prompt for input (there are multiple solutions for how to do this, just make sure you have it straight in your own mind what you are doing when).
INCREMENTAL DEVELOPMENT STEP
When you start working on your program, start with printing out the menu and test it by giving an invalid choice and the logout choice. Don't work on any of the other options until this is working. You can put comments and print out a message for each choice, similar to print("work on choice 1 here"), print("work on choice 2 here"), or print("FIXME: Choice 1 here"), etc within the code where you would work on those things. If you get to the point where you are printing the menu and handling choice 5 and an invalid choice correctly, you should be able to pass the first three test cases.
Registering a Customer
Choice 1 is registering a new customer. If this option is selected from the menu, then the program should prompt the user for a new customer name. If the customer is already in the system, print out an error message and the program should display the menu again and prompt the user for another choice. If the customer is not already in the system, the program should add the new customer, and prompt for the pet's name.The error message in case of an already existing customer should be:
Error. Customer is already registered.
The program will look up the customer name in a list called CustomerNames that is already stored as part of the program. All of the data for a given customer is stored in parallel lists which are given in the starting code. This means that all of the information in each list is in the same order by customer. In other words, if customer "Charlie Brown" is fourth in the list of CustomerNames, their ID will be fourth in the list of CustomerNumbers, their pet's name will be fourth in the list of PetNames, etc. We are making the simplifying assumption that every pet owner has only one pet.
Once a valid customer name and pet name are entered, the program should add data at the end of each list in the system. The default value for a newly registered customer for the CheckInTime list is a string type "MM/DD/YYYY", while the default value for the Duration list is an integer type 0. There is a formula when creating new customer ID's. The ID numbers begin at 1. Every ID number that is created after the number 1 is equal to the length of the current CustomerNumbers list plus the value of the last element in the current CustomerNumbers list. For example, with a CustomerNumbers list of [1, 2, 4, 7, 11], the next ID generated will be 16, since there are 5 customers currently in the list and the last customer number is 11.
Once the data has been added to each list, the program should print out a message displaying the successful data entry that includes the customer name and ID. See below for an example of the expected output. The name is left aligned with 24 characters, and the ID is right aligned with 6 characters. There is a row of 30 dashes between the headings and the data. If the customer name entered is Jackson Meyers, and the pet's name is Tiger, the following output would be produced:
Enter the customer name:
Enter the pet's name:
New customer successfully registered!
Customer Name ID
------------------------------
Jackson Meyers 466
INCREMENTAL DEVELOPMENT STEP
Once you have completed the menu and logout, work on implementing choice 1. When you have completed everything you need to do for choice 1, you should be able to pass the first 7 test cases (which includes the first 3 you passed with the menu). Don't start writing more code until you have passed all of test cases 1 through 7. This will save you aggravation later. If you have completed these steps and passed test cases 1 through 7, congratulations! You have passed the first checkpoint. The steps do get progressively more difficult, so if you finish this quickly, go ahead and start working on choice 2 and 4 for the second checkpoint.
New Check in for a Pet
The second option is checking in a pet. The user is asked to enter the customer's ID with the prompt Enter the customer's ID: followed by a new line. If this ID is invalid (that is, it does not occur in the customer ID list), print an error message. The program should display the menu again and prompt the user for another choice. The error message is:
Invalid customer ID!
If the customer ID is valid (that is, already in the system), the program should check to see if there is already a check-in time associated with that customer that is not the default value. If there is already a check in time, display an error message and go back to the menu. This error message is:
Meredith is already checked in!
where Meredith is the name of the pet for that customer.
If the pet is not checked in yet, prompt for the current date and the duration of the pet's stay. Then print out a message notifying the user of a successful check in. Example output:
Enter the current date (MM/DD/YYYY):
Enter the duration your pet will stay (in number of days):
Gumball Watterson's pet Darwin was successfully checked in.
INCREMENTAL DEVELOPMENT STEP
Once you have successfully coded and tested option 2, you should be able to pass the first 15 test cases. Then start working on option 4, which is to print out all of the customers. If you do this successfully, you will have passed test case 16 through 18 and completed checkpoint 2. Bonus: Since you have already worked out the spacing issues in the menu and a few actions, you won't have to worry about that again and can focus on the additional functionality. Don't move on until you have passed all 18 test cases. Note that it is possible to pass all 18 test cases without completing everything necessary in options 1 and 2; beware that you may need to revisit this code if there is something wrong further down the line (such as you did not update the lists correctly).
Check Out a Pet
The third option is checking out a pet. The user is asked is to enter the customer's ID. If this ID is invalid (that is, it is not in the Customer Id list), print an error message and the program should display the menu again and prompt the user for another choice. The error message is:
Invalid customer ID!
After collecting a valid customer ID, the program should check to see if there is already a check in time associated with that customer. If the check in time is the default value, display the following error message and go back to the menu.
Your pet is not checked in!
If the customer's ID is valid and the check in time is valid, you will then prompt for the current date.
Enter the current date (MM/DD/YYYY):
We will be using the datetime module to calculate the difference between a pet's check in time and check out time. The module is imported in the starter code. Recall from chapter 5 that modules are used to allow you to import functions other people have written so that you don't have to write them yourself. Recall that characters and strings are internally represented in the computer in a different way (an ASCII code, for example) than what we humans usually think about them as. Similarly, a "date" is recognized by we humans as having a year, a month, and a day, but is represented in the computer in a different way. The datetime module has tools to help us with this conversion. You don't need to know the specifics of how dates are stored, just how to use them, as the following examples will show.
To create a date, you must supply the year, the month, and the day, all as integer types. Remember that your dates are all being input as strings, and you will need to get the integer pieces of them. The following is an example on how to create a date with the datetime module:
date1 = datetime.date(2022, 10, 26)
date2 = datetime.date(2022, 11, 11)
will store October 26, 2022 into a variable named date1 and November 11, 2022 into a variable named date2. The computer considers variables date1 and date2 and stores the internally as "date" types (similar to the built in integer, float, and string types). You can do operations like comparisons (<,>, ==), and operations like addition and subtraction on date types as a whole (just like you can with integers), but since they are "date" objects, the module knows how to wrap around month and year boundaries to do the right thing. To get the individual parts of a date that is stored as a result of such an operation, we use dot notation as we have seen before with modules.
So to find the difference between two date types (in days), you must subtract the two dates, then you must extract the days from the result, which is an integer. Subtraction between two dates is different internally than subtraction between two integers, just like the + operation is different on integers vs. strings. The following is an example:
DateDifference = date1 - date2
num_days = DateDifference.days
or, the equivalent:
num_days = (date1 - date2).days
You will need to compare the check in and check out dates to make sure that the check out date is not before the check in date (for example, if the check in date is October 12th, 2022, the check out date cannot be any date before 10/12/2022). If the check out date is invalid, the following error should be displayed.
Invalid date.
Another important part of checking out a pet is making sure all of the defaults are reset as if the pet is not checked in, so that they could be checked in at another time without getting an error message.
You will then calculate and display the total cost for the pet's stay, using the difference in the check in and check out dates. You must compare the duration between the dates with the duration originally specified by the customer to calculate the total cost. The flat rate for each scheduled day a pet is staying is $35.99 per day. Any additional day spent at the daycare will cost $40.99 per day. If the customer's pet overstayed for any duration, you will display the following message:
Your pet's stay has exceeded the specified duration. You will be charged extra for the additional days stayed.
If the pet stays less than the duration originally requested, they should only be charged for the days actually stayed. In other words, if the check in said they were staying 8 days, but they checked out after 4 days, they should only be charged for 4 days.
You will now display the total cost, along with some additional information about the customer. The name is left aligned with 24 characters, and the pet name is left aligned with 14 characters The total should be right aligned with 10 characters, including the decimal point. The Column Headings (the words Owner Name, Pet Name, and Total) should be aligned the same way. An example output is below.
Your total cost is:
Owner Name Pet Name Total
------------------------------------------------
Jonathan Arbuckle Garfield 503.86
Display Customers
The fourth option displays all of the customers, their pet's names, and their pet's duration in the system. .The name is left aligned in 24 characters, the pet's name is left aligned in 14 characters, and the duration is right aligned with 8 characters. A small example output of a system with three customers is shown below:
Owner Name Pet Name Duration
----------------------------------------------
Shaggy Rogers Scooby 10
Emily Elizabeth Clifford 3
Johnny Test Dukey 17
Logout
The fifth option logs the user out of the system. The following goodbye message should be displayed.
Thank you for using the best pet daycare ever!
,>