Question: Week 6 Assignment Modify your program from week 5 so that the program utilizes object-oriented programming to create an application which allows the user to
Week 6 Assignment
Modify your program from week 5 so that the program utilizes object-oriented programming to create an application which allows the user to create, delete or modify orders. Your program should do the following in order:
1. Define a class and class variables
2. Create a function to set the order amount
- Set order amount
3. Create a function to set order type
- Set order type
4. Create a function to set the order number
- Set order number
5. Create a function to get the order amount
- Return the order amount
6. Create a function to get the order type
- Return the order type
7. Create a function to get the order number
- Return the order number
- Modify the function to display the order menu
Display a menu so that the user can select 1 of 6 options:
- Add Order
- Delete Order
- Edit Order
- Display Order
- Save Order
- Exit the Program
- Create a new function to save the order items added to the list in a text file.
- Repeatedly execute the menu selections unit the user enters 6 to exit the program.
Examples of the programs input and output is shown below:
Add and Edit Order
Print, Save, and Exit Order
Order Saved To Text File
Week 5 Assignment
Create a program utilizes functions to append, delete, and index methods discussed this week. Your program should allow the user to add, remove or edit an item from a list. Your program should also print the list values and display a menu for the user to select a menu option. You will need to complete the following steps in your program:
1. Create a list called transactions
2. Create a function to display a menu so that the user can select 1 of 5 options:
- Add Transaction
- Delete Transaction
- Edit Transaction
- Display Transactions
- Exit the Program
3. Create a function to add a transaction to the list
- Ask user to enter transaction key
- Append transaction key to list
4. Create a function to delete a transaction from the list
- Ask user to enter transaction key
- Delete transaction key from list
5. Create a function to edit a transaction from the list
- Ask user to enter transaction key
- Edit existing transaction key
- Create a function to print the list
- Print all transaction keys in the list
- Repeatedly display the menu selections if the user has not selected option 5 to exit the program.
Examples of the programs input and output is shown below:
**********Main Menu***********
- Add Transaction
- Delete Transaction
- Edit Transaction
- Display Transactions
- Exit the Program
Choose a menu option from 1-4 or 5 to exit the program: 1
Enter the transaction key to add: 1234
**********Main Menu***********
- Add Transaction
- Delete Transaction
- Edit Transaction
- Display Transactions
- Exit the Program
Choose a menu option from 1-4 or 5 to exit the program: 4
Displaying transaction keys list:
1234
**********Main Menu***********
- Add Transaction
- Delete Transaction
- Edit Transaction
- Display Transactions
- Exit the Program
Choose a menu option from 1-4 or 5 to exit the program: 3
Enter the transaction key to edit: 1234
Enter the new transaction key to add: 5678
**********Main Menu***********
- Add Transaction
- Delete Transaction
- Edit Transaction
- Display Transactions
- Exit the Program
Choose a menu option from 1-4 or 5 to exit the program: 5
Exiting program.
Week 5 assignment that I turned in
t transaction key from user and add it to transactions list def addTransaction(): tKey = input("Enter the transaction key to add: ") transactions.append(tKey) print("Added") #Get transaction key from user and remove it from transactions list def deleteTransaction(): tKey = input("Enter the transaction key to delete: ") transactions.remove(tKey) print("Removed") #Get transaction key and new transaction key from user #Edit transaction key in transactions list def editTransaction(): tKey = input("Enter the transaction key to edit: ") newKey = input("Enter the new transaction key to add: ") transactions[transactions.index(tKey)] = newKey #Display transaction keys to the user def printList(): print(" ","*"*17,sep="") print("** Transactions **") count = 1 for tKey in transactions: print(count,"."," ",tKey,sep="") count += 1 print("*"*17) #Create transaction list transactions = [] #Initialize choice variable choice = 0 #Run while loop until user select choice 5 while(choice != 5): #Display main menu to the user print("********** Main Menu ***********") print("1. Add Transaction") print("2. Delete Transaction") print("3. Edit Transaction") print("4. Display Transactions") print("5. Exit the Program") #Get choice from the user choice = int(input("Choose a menu option from 1-4 or 5 to exit the program: ")) #If choice is 1, then call addTansaction() if choice == 1: addTransaction() #If choice is 2, then call deleteTansaction() elif choice == 2: deleteTransaction() #If choice is 3, then call editTansaction() elif choice == 3: editTransaction() #If choice is 4, then call printList() elif choice == 4: printList() #If choice is 5, exit program elif choice == 5: print("Exiting Program") #If choice is not 1 to 5, then display invalid message to the user else: print("Invalid option") print(" ")
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
