its an assignment about Advanced Applied Programming please see the pdf file that i attach thanks
assignment_tt.pdf
Unformatted Attachment Preview
Title: Shopping Cart Management System (Part 3)
This is a continuation of the assignment 4. In this assignment, you need to address additional requirements as
described below.
Additional requirements
(1) Supporting additional commands
a.
You need to support two additional commands as changing the user selected item’s (1) name and (2)
price.
(2) Overall, your program must support the following 7 commands. Instead of processing all commands as string
inputs (as you did in the previous assignment 3 and 4), you must change all the commands as digits as shown
below. In detail, the user needs to enter the digits of 1 ~ 7 for initiating an action of each command. To support
the commands, you must use match expression.
a.
Add → 1
b.
Remove → 2
c.
Change
i. Rename → 3
ii. Quantity → 4
iii. Price → 5
d.
Print → 6
e.
Quit → 7
(3) Exception handling
a.
Unsupported commands (other than 1 ~ 7) need to be handled properly with notifying the user – “The
entered command (…) is not valid!”.
b.
Handling incorrectly entered inputs for the quantity and unit price needs to be supported. For
instance, if the user enters “toy” for the quantity, a notification message (“–>The quantity has been
entered incorrectly!”) needs to be printed and ask the user again.
————————————————————————Supported Commands
————————————————————————|
1: Add
|
2: Remove
|
3: Rename the item
|
4: Change the quantity
|
6: Print
|
7: Quit
|
5: Change the price
————————————————————————Enter a command:
1
Enter new item’s name: shoes
Enter new item’s quantity: toy
–>The quantity has been entered incorrectly!
Enter new item’s quantity: ten
Enter new item’s unit price: 300.00
c.
Also, processing string numbers for the quantity need to be supported. As shown above, if the user
enters “ten” for the quantity, it needs to be converted to a numeric value 10. For this requirement, you
must support the following string numbers as “one”, “two”, “three”, “four”, “five”, “six”, “seven”,
“eight”, “nine”, “ten”, “eleven”, “twelve”, “thirteen”, “fourteen”, “fifteen”, “sixteen”, “seventeen”,
“eighteen”, “nineteen”, “twenty”.
For Scala programming, you can simply use “indexOf” method. For example, if the user enters “two”
as a String value, it can be compared with all string numbers stored in the Array (“numStrings”).
Since the index number starts from 0, plus 1 needs to be applied to get a correct numeric value.
val numStrings = Array(“one”, “two”, “three”)
val intValue:Int = numStrings.indexOf(“two”) + 1
println(intValue)
PROCESSING COMMAND(S)
For any invalid commands, a notification message must be printed on screen.
========================================================================
Shopping Cart!!
————————————————————————Supported Commands
————————————————————————| 1: Add
| 2: Remove
| 3: Rename the item | 4: Change the quantity | 5: Change the price
| 6: Print
| 7: Quit
————————————————————————Enter a command: test
The entered command ( test ) is not valid!
————————————————————————Supported Commands
————————————————————————| 1: Add
| 2: Remove
| 3: Rename the item | 4: Change the quantity | 5: Change the price
| 6: Print
| 7: Quit
————————————————————————Enter a command: 0
The entered command ( 0 ) is not valid!
————————————————————————Supported Commands
————————————————————————| 1: Add
| 2: Remove
| 3: Rename the item | 4: Change the quantity | 5: Change the price
| 6: Print
| 7: Quit
————————————————————————Enter a command: 1
Enter new item’s name: shoes
Enter new item’s quantity: five
Enter new item’s unit price: 300
————————————————————————Supported Commands
————————————————————————| 1: Add
| 2: Remove
| 3: Rename the item | 4: Change the quantity | 5: Change the price
| 6: Print
| 7: Quit
————————————————————————Enter a command: ADD
–>The entered command ( ADD ) is not valid!
————————————————————————Supported Commands
————————————————————————| 1: Add
| 2: Remove
| 3: Rename the item | 4: Change the quantity | 5: Change the price
| 6: Print
| 7: Quit
————————————————————————Enter a command: 1
Enter new item’s name: Banana Mango
Enter new item’s quantity again: 2
Enter new item’s unit price: 10
————————————————-* Note that the red colored text indicates the user entered text.
REMOVE ITEM(S)
When the user wants to remove, a list of items in the cart needs to be printed. Also, it is necessary to ask the user to
enter an item number for removal. Any incorrectly entered information needs to handled by showing a warning
message (“–>The item number has been entered incorrectly!”).
————————————————————————Supported Commands
————————————————————————| 1: Add
| 2: Remove
| 3: Rename the item | 4: Change the quantity | 5: Change the price
| 6: Print
| 7: Quit
————————————————————————Enter a command: 2
1: name: Shoes, quantity: 5, unit price: $300.50
2: name: Mango, quantity: 10, unit price: $10.00
Enter the item number that you want to remove: shoes
–>The item number has been entered incorrectly!
Enter the item number that you want to remove: 0
–>The item number has been entered incorrectly!
Enter the item number that you want to remove: 1
The item number (1) has been removed successfully.
————————————————————————Supported Commands
————————————————————————| 1: Add
| 2: Remove
| 3: Rename the item | 4: Change the quantity | 5: Change the price
| 6: Print
| 7: Quit
————————————————————————Enter a command: 2
1: name: Mango, quantity: 10, unit price: $10.00
Enter the item number that you want to remove: 1
The item number (1) has been removed successfully.
————————————————————————Supported Commands
————————————————————————| 1: Add
| 2: Remove
| 3: Rename the item | 4: Change the quantity | 5: Change the price
| 6: Print
| 7: Quit
————————————————————————Enter a command: 2
–>There is no item to remove!
————————————————-* Note that the red colored text indicates the user entered text.
CHANGE THE NAME OF THE ITEM(S)
This command is for changing the name of the selected item(s).
————————————————————————Supported Commands
————————————————————————| 1: Add
| 2: Remove
| 3: Rename the item | 4: Change the quantity | 5: Change the price
| 6: Print
| 7: Quit
————————————————————————Enter a command: 3
1: name: Shoes, quantity: 5, unit price: $300.50
2: name: Mango, quantity: 10, unit price: $10.00
Enter the item number that you want to adjust the quantity: shoes
–>The item number has been entered incorrectly!
Enter the item number that you want to adjust the quantity: 0
–>The item number has been entered incorrectly!
Enter the item number that you want to adjust the quantity: 1
Enter new name of the item: Toy
The name of the item number (1) has been changed successfully.
* Note that the red colored text indicates the user entered text.
ADJUST THE QUANTITY OF THE ITEM(S)
This command is for adjusting the quantity of the selected item(s). Any incorrectly entered information needs to be
processed by showing a warning message.
————————————————————————Supported Commands
————————————————————————| 1: Add
| 2: Remove
| 3: Rename the item | 4: Change the quantity | 5: Change the price
| 6: Print
| 7: Quit
————————————————————————Enter a command: 4
1: name: Shoes, quantity: 5, unit price: $300.50
2: name: Mango, quantity: 10, unit price: $10.00
Enter the item number that you want to adjust the quantity: shoes
–>The item number has been entered incorrectly!
Enter the item number that you want to adjust the quantity: 0
–>The item number has been entered incorrectly!
Enter the item number that you want to adjust the quantity: 1
Enter new quantity of the item: 10
The quantity information of the item number (1) has been changed successfully.
* Note that the red colored text indicates the user entered text.
ADJUST THE PRICE OF THE ITEM(S)
This command is for adjusting the quantity of the selected item(s). Any incorrectly entered information needs to be
handled with showing a warning message.
————————————————————————Supported Commands
————————————————————————| 1: Add
| 2: Remove
| 3: Rename the item | 4: Change the quantity | 5: Change the price
| 6: Print
| 7: Quit
————————————————————————Enter a command: 5
1: name: Shoes, quantity: 5, unit price: $300.50
2: name: Mango, quantity: 10, unit price: $10.00
Enter the item number that you want to adjust the quantity: shoes
–>The item number has been entered incorrectly!
Enter the item number that you want to adjust the quantity: 0
–>The item number has been entered incorrectly!
Enter the item number that you want to adjust the quantity: 1
Enter new price of the item: 100.00
The quantity information of the item number (1) has been changed successfully.
* Note that the red colored text indicates the user entered text.
PRINT THE ITEM(S)
This command is for printing all items in the cart. At the same time, total sum needs to be printed.
————————————————————————Supported Commands
————————————————————————| 1: Add
| 2: Remove
| 3: Rename the item | 4: Change the quantity | 5: Change the price
| 6: Print
| 7: Quit
————————————————————————Enter a command: 6
1: name: Shoes, quantity: 10, unit price: $300.50
2: name: Mango, quantity: 10, unit price: $10.00
Total Sum: $3,105.00
* Note that the red colored text indicates the user entered text.
NAMING REQUIREMENTS:
Your IntelliJ project should be named as “YourLastname_Assignment05”.
Your Scala source code must be named as “YourLastname_Assignment05.scala”. When compiled
successfully (with no compilation error), IntelliJ generates the file “YourLastname_Assignment05.jar”.
You need to zip two files (YourLastname_Assignment05.scala and YourLastname_Assignment05.jar) as
“YourStudentID_Assignment05.zip”. For instance, if your student ID is N012345, the zip file name must
be N012345_Assignment05.zip. Submit the zip file to the Blackboard.
HINTS:
In your program, you must create an object named as “YourLastname_Assignment05”. Inside of the object,
you need to create a main method as “def main(args: Array[String])”.
For handling commands, you must use match expression (see Lecture 5).
To support exception handling, you must use try… catch statement (see Lecture 5).
Requirements (& Grading policy):
1.
You need to add your name and student id in the first line of the program. (2pt)
2.
You must add comments in your source codes (possibly most lines). (15pt)
3.
Processing all commands as numeric values (instead of processing them as string values). (8pt)
4.
All commands need to work as described above (24pt)
o
Otherwise, deduction (up to 4pt per each command 1 ~ 6) will be applied.
5.
Using try…catch statement for exception handling for incorrectly entered quantity and price. (2pt)
6.
Processing the user entered string numbers for the quantity and price as numeric values (6pt)
7.
You need print the unit price and the total price of items with a leading dollar sign, a comma used as the
grouping separator, and a period used as the decimal indicator. For example, $1,234.56. (2pt)
8.
Your program source code must be named as “YourLastname_Assignment05.scala”. (2pt)
9.
Your jar file must be named as “YourLastname_Assignment05.jar”. (2pt)
10. You need to zip the two files (YourLastname_Assignment05.scala and YourLastname_Assignment05.jar)
as “YourStudentID_Assignment05.zip”. For instance, if your student ID is N012345, the zip file name
must be N012345_Assignment05.zip. Submit the zip file to the Blackboard. (2pt)
…
Purchase answer to see full
attachment