CSCE 101 project #4: Travel Management System, Python Classes
Due Friday, March 9, 11:59pm, via Canvas.
In the Files folder is a folder named project4, it contains:
1. A Python program, named travelSystem.py.
2. The Python application program interface (API) in travelClassAPI.py defining a class travelItem. (You will complete this file as travelClass.py.)
3. The Python API in travelToolboxAPI.py defining four functions. The functions readItems() and printItems() are complete, but the files readTransactions() and printTransactions() are only declarations of the interfaces. (You will complete this file as travelToolbox.py.)
4. Two text files that provide one test example, items4.csv and transactions4.csv. (You will want to create similar test files.)
a. The items file is a sequence of lines, each of which has three comma-separated values:
i. A unique tour ID (a string).
ii. The name of that tour (a string).
iii. The starting availability of seats for the tour (an integer).
For example:
12345,Italy,100
If a string value in a CSV file includes a comma, it is enclosed in quotation marks.
b. The transactions file is a sequence of lines, each of which has two commaseparated values:
i. A tour ID (a string), for which there is a corresponding item in the items4.csv file.
ii. The number of seats for the transaction with that item (an integer). For example:
12345,10
A positive integer indicates a reservation and a negative integer indicates a cancellation.
You are to complete the class travelItem in travelClass.py (from travelClassAPI.py) and the functions in travelToolbox.py (from travelToolboxAPI.py).
• This will give you the experience of working on an existing code base, something that is common in software development. You will need to read and understand the existing code, which is a necessary and valuable skill.
• I suggest that you write and test your work in the following order.
1. The definition for the class travelItem in travelClass.py. It will be similar to the example shown in class (available as travelDemoClass.py). You should write a little program to test it (along the lines of travelDemo.py).
2. The readTransactions() function, which will require you to understand and use the itemRecords dictionary, and which is similar to the readItems() function.
3. The printSummary () function so you can print the required output. This function must print output in the following format (for which I will post a hint on the Discussion Board):
Tours
=====
ID NAME Start Resv. Cancl. End
—– ———— —— —— —— ——
24680 France 50 10 0 40
12345 Italy 100 35 -10 75
13579 China 50 10 -10 50
• In the program travelSystem.py, which is provided, you will see that the variable itemRecords is a dictionary with keys of item ID (a string) and values of objects of the travelItem class. You can see that the function readItems() creates this dictionary. You will need to use this dictionary when you write readTransactions() to read the transactions. When you read a transaction, you will look up the object for that item using its ID as the key and then append the number of items for the transaction to the list of transactions in that object.
• All of this may sound intimidating, but my solution has only 14 additional statements for travelClass.py (other than those which are identical to the example shown in class) and 17 additional statements for travelToolbox.py (most of which are similar to those in readItems() and printItems() and many of which are print statements). However, this requires many simple things that must work together, and putting those simple things together is the challenge.
Here are core specifications for the software.
1. Input.
a. Your program will read the file items4.csv, which is an example input file, but you will want to make other test files.
b. Your program will file the file transactions4.csv, which is an example input file, but you will want to make other test files.
2. Starting Availability. The availableStart for each tour is provided in items4.csv.
3. Reservations. The number of reservations for each tour is computed as the sum of all positive integers for that tour from transactions4.csv.
4. Cancellations. The number of cancellations for each tour is computed as the sum of the negative integers for that tour from the file transactions4.csv.
5. Ending Availability. The availableEnd for each tour is computed as availableStart minus the number of reservations and cancellations for that tour.
6. Output. The output is printed by printItems() and printSummary() in travelToolbox.py.
You must:
• Complete the files travelClass.py (from travelClassAPI.py) and travelToolbox.py (from travelToolboxAPI.py).
• Add four lines of comments at the top of your files:
# Author:
# Course: CSCE 101
# project: 4 – Travel Management System, Python Classes
# Date: 9 March 2018
You must use Canvas
Use Canvas to submit your two Python files.
Grading Rubric
Required Elements:
Submitted program (30 points).
Program executes without run-time error (maximum 20 points).
Program executes given test case correctly (maximum 30 points).
Program executes additional test cases correctly (maximum 20 points).
Stylistic Elements:
Comments, sections, organization, brevity, readability, output formatting, etc. (between –10 and +10 points).
Total: Maximum 110 points.
Scores should reflect the following subjective scale:
>100 Exceptional.
>=90 Outstanding.
>=80 Good.
>=70 Acceptable.
>=60 Poor.
<60 Unacceptable.
1513067809116994.png
CS案例:python案例CSCE 101 Travel Manage
2018-05-30