I really need help with this assignment
FINAL PROJECT COMP202, Winter 2021 Due: Friday, April 30th, 11:59pm Please read the entire PDF before starting. You must do this final project individually. Question 1: 100 points 100 points total It is very important that you follow the directions as closely as possible. The directions, while perhaps tedious, are designed to make it as easy as possible for the TAs to mark the assignments by letting them run your assignment through automated tests. To get full marks, you must: • Follow all directions below. – In particular, make sure that all file names and function names are spelled exactly as described in this document. Otherwise, you will not be awarded points for those modules/functions. • Make sure that your code runs. – Code with errors will receive a very low mark. • Write your name and student ID as a comment at the top of all .py files you hand in. • Name your variables appropriately. – The purpose of each variable should be obvious from the name. • Comment your work. – A comment every line is not needed, but there should be enough comments to fully understand your program. • Avoid writing repetitive code, but rather call helper functions! You are welcome to add additional functions if you think this can increase the readability of your code. • Lines of code should NOT require the TA to scroll horizontally to read the whole thing. Vertical spacing is also important when writing code. Separate each block of code (also within a function) with an empty line. Please note that the final project must be submitted by April 30th. There are NO late days available for the final project. If you do not submit the project by April 30th, you will be re- ceiving a 0 on this assessment and your final course grade will be computed accordingly. Please also note that it is NOT necessary to submit the project in order to pass the course. 1 The Final Project In this project you will be implementing several modules that will allow you to simulate a booking system for hotels. This project will allow you to better understand how to read and write to files, how to write objected oriented programs, and how to plot data using Matplotlib. For full marks Note that the project is designed for you to be practicing what you have learned in the videos up to and including Week 13. For this reason, you are NOT allowed to use anything seen after Week 13 (e.g., NumPy) or anything not seen in class at all. You will be heavily penalized if you do so. Examples For each function/method, we provide examples of how your code should behave. All examples are given as if you were to use them within your docstring. When you upload your code to codePost, some of these examples will be run automatically to check that your code outputs the same as given in the example. However, it is your responsibility to make sure your code/functions work for any inputs, not just the ones shown in the examples. When the time comes to grade your project, we will run additional, private tests that may use inputs not seen in the examples. Furthermore, please note that your code files should not contain any function calls in the main body of the program (i.e., outside of any functions). Code that does not conform in this manner will automatically fail the tests on codePost and be heavily penalized. It is OK to place function calls in the main body of your code for testing purposes, but if you do so, make certain that you remove them before submitting. Please review what you have learned in video 5.2 if you’d like to add code to your modules which executes only when you run your files. About the data With this PDF you will be given a zip file containing a folder called hotels. Unzip this file so that the hotels folder is in the same folder as the Python code files that you will make for this project. Inside the hotels folder, there will be one folder for each hotel that your booking system will manage. At the moment, there are two hotels, but you can add more for testing purposes. (Note that some examples for the methods below require that you test with the given hotels folder with no modifications.) Inside each hotel folder, there will be a hotel_info.txt file. This file contains the name of the hotel on the first line, followed by one line for each room in the hotel. Each of these lines will have three pieces of data separated by commas: the room number, the room type, and the price per night. Also inside each hotel folder will be a number of CSV files, one for each month in which the hotel has rooms to be reserved. The name of each file will have the year, followed by an underscore, followed by the month (e.g., 1975_Oct.csv). Inside each CSV file will be one row for every room in the hotel. The first column will indicate the room name. Subsequent columns will indicate the reservation, if any, for the room on the day corresponding to the column (column 1 is day 1, column 30 is day 30, etc.). The reservation will be indicated by the booking number, followed by two hyphens, followed by the name of the person who reserved the room (e.g., 9998701091820--Jack). Note that CSV stands for comma-separated values file. What this means is that each line of the file contains what is called a data record. Each record consists of strings, separated by commas. The commas are what creates the columns. You need to keep this in mind when reading/writing a csv file. (UPDATED on Apr 17) Page 2 Safe Assumptions You can assume the following: • Every column of the data will be present, even though some data might be missing (i.e., some columns may simply contain an empty string). • There are no spelling mistakes. • The order in which the data appears follows the format described above. • There are no entries (i.e., no rows) with the same room number. • Your functions will always be tested with correct input, so no input validation is required, unless explicitly stated in the description of the functions/methods. • If not otherwise specified, functions/methods working with strings should be case sensitive. (UP- DATED on Apr 17) Objects of type date In this project you will be working with objects of type date. Python offers a module called datetime that can help you with this. Here are few things you can do with objects of type date: • You can create and use date objects as follows: >>> import datetime >>> date1 = datetime.date(2021, 4, 16) # Year, month, day >>> print(date1.year) 2021 >>> date2 = datetime.date(2021, 4, 30) >>> print(date2.month) 4 • You can subtract two date objects. The result is a timedelta object, which has one attribute: days. This is how many days apart the two dates are. For example: >>> diff = date2 - date1 >>> diff.days 14 • A __str__ method has been implemented for objects of type date. The method returns the year, the month, and the day of the date joined together with a hyphen. For example: >>> print(date1) 2021-04-16 • The operators <,> and == have been overloaded. A date is considered to be smaller than another date if it happens to represent an earlier date. It is considered to be larger if it represents a later date. For example: >>> date1 < date2="" true="">>> date2 > date1 True >>> date1 > date2 False >>> date3 = datetime.date(2021, 4, 16) Page 3 >>> date1 == date3 True • A ValueError is raised whenever one tries to create an object of type date with inputs that are considered to be out of range. For example: >>> datetime.date(2021, 1, 35) Traceback (most recent call last): File "
", line 1, in ValueError: day is out of range for month >>> datetime.date(2021, 0, 12) Traceback (most recent call last): File "", line 1, in ValueError: month must be in 1..12 >>> datetime.date(2021, 2, 29) Traceback (most recent call last): File "", line 1, in ValueError: day is out of range for month >>> datetime.date(2020, 2, 29) # No error is raised because 2020 was a leap year! datetime.date(2020, 2, 29) • You can read more here: https://docs.python.org/3/library/datetime.html Filesystem paths In this project you will need to open files for reading and writing that are contained within sub-directories of the current folder. So far, when we read and write to files, the files have always been in the same folder as our Python code files. If we want to open a file that is within a sub-directory (that is, within a folder that is in the current folder), then we must indicate the sub-directory’s name in the filename that we give to the open function. For example, if there is a file x.txt inside a folder called files, and the folder called files is in the same folder as our Python code file, then to open x.txt, we would use files/x.txt as the file path given to the open function. If a file is contained within a sub-directory of a sub-directory, then we just extend the path by placing another forward slash and the other sub-directory name. For example, if we want to open the hotel_info.txt file, which is inside a folder called overlook_hotel, which itself is in a folder called hotels, and our Python code file is in the same folder as the hotels folder, then to open the file we would use hotels/overlook_hotel/hotel_info.txt as the file path given to the open function. Question 1: Hotel reservation system (100 points) Room Create a module called room.py and place your name and student ID at the top. All the functions in this section will go inside this module. You may not import any modules other than doctest and datetime. Inside this module define the two following global variables at the top of the file. Note that we define these global variables in all uppercase because they are ‘constants’: variables that will never change throughout the execution of the program (although the programmer may decide to alter them between executions). Page 4 • MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] • DAYS_PER_MONTH = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] Then, create a class called,>