Project Management

Problem Description:
In this project, you are required to build a system that helps users explore new books from their favorite genres while maintaining their purchasing budget requirements. The system tracks users that want to ensure that their chosen books do not exceed their budget. To perform this tracking, the system creates user profiles by storing personal and financial information in a file. This allows users to load their information and use it to generate books. The system should generate for the users (5 – 10) random book recommendations from a file. Based on the user budget and genre-specific requirements, the system can calculate and display statistics about the spending’s of each recommendation session and the overall user progress in terms of keeping up with their budget goal.

The program should be menu driven to allow the users to choose one of the following tasks:

  1. Create or load a user profile
  2. Edit or delete a user profile
  3. View user profile
  4. Generate book recommendations for the user
  5. View user books and generate budget information
  6. Exit the program

Here are the details of each choice that the user will be able to perform in the program:

  1. Create or load a user profile
    When the user chooses 1, the program should perform the following tasks:
    a. Check if the file ‘userInformation.txt’ exists, if it does not exist (i.e., you are running the program for the first time ever), create a new user profile by asking the user to enter the following fields to the userInformation.txt file in append mode, like the following sample input:

Join Date (string) Name (string) Year of birth (integer) Age (integer) Gender (string) Budget (float) Medium (string) Genres
(list of strings)
17/10/2020,
05:38:26 Maryam 1992 28 Female 67.0 Physical books Family,
Plays

• From the year of birth, calculate the user age. Asking the user to enter their date of birth and calculating the exact age in years is a bonus.
• The gender should be a string that corresponds to either female or male only.
• Ask the user to enter their estimated budget per book in Qatari Riyal. The entered budget cannot be less than 12 QR. If the user enters a budget below 12, ask them to enter another budget value.
• Show the user the following list of possible reading mediums to choose from:
1) Printed (i.e., physical books)
2) Digital (i.e., E-books)
3) Both digital and physical books
• The user should enter the number that corresponds to the medium that they prefer. Use a dictionary to map the number to the medium description.
• Read the file genres.csv, which contains a table of all the genres from all the books in this project and show this table to the user as follows: Number\tGenre. Number here corresponds to the line number in which the genre appears in the file, it should also be the number that the user can enter to select a particular genre.
• Ask the user to enter the number of the genre that they are interested in. The user should keep entering the number of the genre or enter -1 to stop entering genres. If the user is not interested in any specific genre, they can just enter -1 and the field Genres will be empty (empty genres are allowed).
• Once you get all the user information, store it in the userInformationFile.txt in append mode using the following order (with \t as a separator):
Join_date\tName\tYearofBirth(or DOB for bonus)\tAge\tGender\tBudget\tMedium\tGenres\tEditDate
• Get the current date and time as a variable, called Joindate and convert it to string, then write it to the userInformation.txt file.
• For now, keep the field EditDate empty, you will fill it later.

b. If the file ‘userInformation.txt’ exists, ask the user if they created a profile before. If the user answers no (n or N), show the user all the steps in (a). However, if the user answers with yes (Y or y) (i.e., they did create a profile before and the information exists in the file userInformation.txt), perform the following:
• Ask the user to enter the name that they used to register their profile.
• Open the file userInformation.txt in read mode, and search for the user information using the name that the user provided.
• If the user makes a spelling mistake, keep asking the user to enter their name until it is found in the file.
• If the user name is found successfully in the userInformation.txt file, load it in the program (i.e., return the information to the user).

  1. Edit or delete a user profile
    When the user chooses 2, the first thing that it should do is to check whether the user information is loaded in the program (i.e., check if the user information is passed to the function that generates recipe recommendations). If the user information is passed to the function (i.e., the user chose option 1 before choosing option 2), the program should show the user the following menu:
    Hello (user name)
    You can perform one of the following operations:
    1) Delete your profile
    2) Edit your profile
    a. If the user chooses 1, perform the following subtasks to delete a user profile:
    1- Search for the user profile in the file userInformation.txt using the user name in read mode; once you find the user profile (i.e., the line that contains all the user information), pass it to a function that deletes the user information.
    2- The function should create a temporary file called temp.txt in write mode and search the file userInformation.txt in read mode for the user that you want to delete (the user returned by the previous step). Write all the content of the file userInformation.txt in the file temp.txt so long as the user is not there, in other words, do not write (delete) the user. The end of this process should yield a file called temp.txt that does not include the user.
    3- Use the os module to delete the file userInformation.txt, then use it to rename the file temp.txt as userInformation.txt.
    4- Print to the user a message stating that the record was deleted successfully.
    5- If the file userInformation.txt contains just one user profile and you chose to delete this user, delete the file.
    6- Make sure you also delete or clear the contents of the variable userInformation when you return to the main menu after successfully deleting the user profile.
    b. If the user chooses 2, perform the following subtasks to edit a user profile:
    Show the user the following menu, which displays the records that they can edit:
    Hello (user name)
    These are the fields that you can edit in your profile:
    1) Name
    2) Year of birth (or Date of Birth for bonus)
    3) Gender
    4) Budget
    5) Medium
    6) Favorite genres
    1- If the user enters the number 1, perform the following:
    1) Ask the user to enter their new user name.
    2) Create a new record of user information that replaces the old name with the new name but keeps all the other fields the same (use string concatenation to do this).
    3) Add the edit date to the end of the new user information record, this date corresponds to the date and time in which the user edited their profile.
    4) Then, call a function that takes the old user information and the new user information.
    5) The function should read the contents of the file userInformation.txt and write it to the file temp.txt, at the same time, search for the old user information, if found, replace it with the new user information and write it to the file temp.txt.
    6) Just like what you did in deleting a file, delete the file userInformation.txt, then rename the file temp.txt to userInformation.txt.
    7) Make sure you also delete or clear the contents of the variable userInformation when you return to the main menu after successfully deleting the user profile.
    2- If the user selects the number 2, perform the following:
    1) Ask the user to enter their new year or date of birth, using this information, re-calculate the user age.
    2) Create a new record of user information that replaces the old year of birth or date of birth with the new information, replace the age with the new age, keep the other fields the same (use string concatenation to do this).
    3) Repeat steps 3) to 7) from (a).
    3- If the user selects the number 3, perform the following:
    1) Ask the user to enter their new gender..
    2) Create a new record of user information that replaces the old gender with the new gender. The other fields should remain the same (use string concatenation to do this).
    4- If the user selects the number 4, perform the following:
    4) Ask the user to enter their new budget.
    5) Create a new record of user information that replaces the old budget with the new budget, keep the other fields the same (use string concatenation to do this).
    6) Repeat steps 3) to 7) from (a).
    5- If the user selects the number 5, perform the following:
    7) Ask the user to enter their new favorite medium.
    8) Create a new record of user information that replaces the old medium with the new medium, keep the other fields the same (use string concatenation to do this).
    9) Repeat steps 3) to 7) from (a).
    6- If the user selects the number 6, perform the following:
    1) Ask the user to enter the new list of genres, just like the way you did when the user creates anew profile.
    2) Create a new record of user information that replaces the old genres with the new genres but keeps all the other fields the same (use string concatenation to do this).
    3) Repeat steps 3) to 7) from (a).
  2. View user profile
    When the user chooses 3, the first thing that it should do is to check whether the user information is loaded in the program (i.e., check if the user information is passed to the function that generates book recommendations). If the user information is not passed to the function (i.e., the user did not chose option 1 before choosing option 3), call the function that allows the user to either load or create a user profile (option 1 from the main menu). Otherwise, perform the following tasks:
    • Open the file userInformation.txt in read mode and retrieve (i.e., read) and print the following user information:
    o Join date
    o Edit date (if available, don’t show it if it doesn’t exist)
    o User name.
    o Year of birth or date of birth as bonus.
    o Age.
    o Gender.
    o Budget per book.
    o Favorite medium.
    o Favorite genre(s).

Sample Solution

ACED ESSAYS