- 1. Introduction
- 2. Expected files
- 3. Links to Reference
- 4. Flow of Program
The program that is written is for APU UCDF2005(DI) Python Assignment.
The assignment requires us to write out a car rental system with people logging in with different roles. Each role will have a text file containing their login credentials, named after their roles. (e.g. role: admin, text file: admin_login_credentials.txt)
Every role will have different priveleges. All priveleges are listed in the Assignment File.
This section contains all the expected files for this assignment.
- main.py: The python file where all the code goes
- customer2.txt: Text file contaning all credentials of users, including the usernames, passwords, names, age, address, contact no. and so on
- car2.txt: Text file containing the details of cars, including car names, brand, model, status (available or rented), duration being rented, price
- admin2.txt: Text file containing the details of Admins
- Documentation: Converted from a Word file about the program written.
- Instruction/Assignment Question: Assignment File
- Python Tutorial: Create a Simple Login System Using a Text File
- python login system tutorial (For beginners) Python Tutorial
- [Searching and Replacing specific text in a file](C:\Users\Asus\Downloads\Python\APU Python lecture and tutorial\Lab 5\Q4.py)
- [Searching and replacing specific text in a file](C:\Users\Asus\Downloads\Python\APU Python lecture and tutorial\replacing string in file\test.py)
- It would show the 2 options (Admin & Customer) or 3 options (Admin, Member, Other). For other, it is the unregistered customer. If use 3 options, the "Skip" in register screen will useless
- If it is customer, there would be an extra option which is "Skip" for the user to not register or login as they might just want to browse through the catalog
- When registering, we need to include details other than username and password. Other details (listed below) must also be included.
- All details will be appended into the text file
- All details must follow the order that is set, which is:
- Username
- Password
- Full name
- IC/Passport number (4)
- Admin ID (For Admins Only)
- Age
- Phone Number
- Address
- Payment/Amount Paid (For Customers Only)
- Amount Due (For Customers Only)
- Bookings (For Customers Only)
- No. of Cars Rented/Purchase History (For Customers Only)
- Rental Duration (For Customers Only)
- Admin and Customers will have their information appended to different files, which will be accepted as an argument in register() function.
- Before registering, the system must check whether the user is already registered (It can be in another function or be in the same function)
- User will need to input their username/email and password
- Validation of the input will be done in another function named validate_user()
- After logging in, there will be a global variable named granted which would be True if Login is successful (validate_user() returns True).
- One function for accessing the user's priveleges. Differentiated by their role
- Just use quit() or break.
- List out all their privileges/options that are listed in the Assignment File.
- A text file called Car_Records.txt is available with the Car Name, Car Brand, Car Model, Seats, Fuel Type, How many doors, How many luggage can it carry, Short description, Status(rented, pending, available), duration left being rented(if status is rented) Reference from Avis
- To add these details, open the file using open(filename, 'a') and then write to the file.
- Order of the Car Details:
- Plate Number*
- Car Name*
- Car Model
- Owner's name
- Status*
- Duration left being rented
- Short Description*
- Seats*
- Fuel Type*
- Price*
- Car Details should be saved as a list
- Able to modify all car details as well as removing the details.
- To modify the details, first check for the car name and owner's name (using if...else statement) and then use filename.replace('word_to_be_changed', 'new_word'). Reference
- Can be made into a function that accepts 2 arguments ('word_to_be_changed', 'new_word').
- To display only cars that are rented out, can use if...else statement to filter out the Status of the cars then print them out. (Refer to the Cars_Records.txt)
- To display only cars that are available, can use if...else statement to filter out the Status of the cars then print them out. (Refer to the Cars_Records.txt)
- To display only customers' bookings (Refer to the Customer_Records.txt)
- To display only customers' payment (Refer to the Customer_Records.txt)
- When user select options 1 and 2, it is automatically printed out because no input is needed.
- When user select options 3 and 4, the system requires an input (probably by month is best) so that the system can check for data in that month. (Probably need to 'import datetime')
- To display only customers' bookings, we can use if...else statement to filter out base on the customer name then print them out. (Refer to the Customer_Records.txt)
- To display only customers' payment, we can use if...else statement to filter out base on the customer name then print them out. (Refer to the Customer_Records.txt)
- User needs to input the customer name to make the search. So use if customer_name in line_of_file then print the information
- I think this is just Modifying Car Details part but only specific to the status and duration of the car. (Update details of car and customer)
- Show all car details except status, owner's name and duration. Only cars that are available are shown.
- Details that can be modified:
- Username
- Password
- Full Name
- IC/Passport Number
- Age
- Address
- Phone Number
- Include all Car Details
- Accepts input (sentinel loop, meaning keep asking until the user say quit) where the user select which detail to modify.
- To modify, use the same method as the admin
- Whenever the customer rents a car, append it into a list.
- When the customer wants to view its purchase history, search for the customers name, by filtering based on his/her username then do print(*[list_of_cars], sep='\n')
- Search through the car2.txt for the customer's Full Name and print out all the cars that have the same match
- The cars that are printed out must have the status 'available', if rented, show 'rented'.
- Display all cars that are available that does not belong to the user
- Make it menu-driven like how they would choose the options on what to do next.
- When they select the car, the user needs to make another input on how many days they are renting the car. After the input, use datetime to calculate the end of the rental and tell the user. Save the end date of rental to a variable so that the system can update the Car_Records.txt after the user make the payment
- Once all the details are keyed in by the user, set the selected car's status to pending
- This is not in the main option menu. This will only appear after the Renting section where the input will be asked to "Continue to Payments" or "Continue Browsing" or "Cancel Booking".
- If "Continue to Payments", the system will check for the duration of days and multiply with the renting rate of the selected car.
- After calculation, the system will display the price then ask for payment method (Credit/Debit Card, Direct Debit, PayPal)
- If Credit Card/Debit Card, ask for:
- Card Number
- Card Owner Name
- Expiry date
- CVV
- If Direct Debit:
- Show the account information of the Rental Company bank, including:
- Bank Name
- Account Number
- Account Name
- Account Currency
- Account Type
- Show the account information of the Rental Company bank, including:
- If PayPal:
- Request PayPal email
- Request PayPal password
- Should we include PayPal?
- After payment is completed, using the variables set in the previous section, update the Car_Records.txt
So when the admin/customer selects one of the options after logging in, they need to have a button/option to go back to the main option menu screen. Since the main options are numbers, I think we can make going back to the main menu a letter like "Y" so that the user can choose other stuff to do without logging in several times. So the menu might look like:
Example of Main Option Menu (for Admin): [1] Adding Cars to be Rented Out [2] Modifying Car Details [3] Display records [4] Search records [5] Return Rented Car [6] Log Out
Example of Modifying Car Details:
Example of Display records: Display Records of: [1] Rented cars [2] Available cars [3] Customer Bookings [4] Customer Payments [Y] Return to Main Menu