java 代写-CSCI 101
时间:2021-05-05
CSCI 101: Quiz3
Design an e-Commerce experience using java.

Using Java, design and create an ecommerce store. The store has a catalog items listed in
catalog.txt file, attahched. When you run your main method, your logic first presents the user
with the following main menu:

*** Main Menu***
Select one of the following options by entering the digit next to it:

1. List the store catalog items
2. Add an item to your cart
3. Remove an item from your cart
4. Change the quantity of an item in your cart
5. View the items in your cart
6. Empty your cart
7. Checkout
9- Exit store

Store Functionality

List the store catalog items
When the shopper selects this option, your code would load the items from the attached file
called, catalog.txt and display it to the user in the console. Then display the main menu and ask
the user to select an action by entering one of the digits.
Catalog.txt is structured as follows
Item Id Description Category Quantity unit price

Add an item to your cart
- When the shopper selects this option, your logic must ask the user to enter item id and
then enter the quantity.
- If the user enters an item id that is not in the catalog, then your logic should handle it
gracefully and display exception message “The item is not found” then display the main
menu
- If the user enters more quantity than what’s available in the catalog, present the user
with a graceful exception message “The requested quantity is more than what’s
currently available” then display the main menu
- Once the item id and the quantity are valid, add the item and the quantity into the
shopping cart then display the message “item is added to your cart”, then display the
main menu

- If the item exists already in the cart, make sure the total quantity is not exceeding
what’s offered in the catalog.

o If the total quantity is exceeding what’s in the catalog, present the user with a
graceful exception message “The requested quantity is more than what’s
currently available” then display the main menu



Remove an item from your cart
- When the shopper selects this option, your logic must ask the user to enter item id that
needs to be removed from the cart.
- Validate the item id is indeed in the cart and remove it.
o If the user enters an item id that is not in the cart, handle it gracefully by
displaying the error message “The item id is not in the cart” then display the
main menu.
o If the item is in the cart, you remove it, display a message “item removed
successfully” then display main menu

Change the quantity of an item in your cart
- When the shopper selects this option, your logic must ask the user to enter item id and
the new quantity that need to be updated in the cart
- Validate user input,
o if the user input incorrect item id, display the exception message, “The item not
found” then display the main menu.

- if the user enters quantity greater than what’s in the catalog, handle it gracefully and
display the exception message “The requested quantity is more than what’s currently
available” then display the main menu”
- If the user enters quantity of zero, remove the item from the shopping cart, and display
a message, “item removed from cart”, then display the main menu

View the items in your cart
- When the shopper selects this option, display the content of the cart as follows (each
column is 20 char width)
Item Id Item Description Item Quantity Item Category Unit Price Total Price

- Then display the main menu and ask the user to select an action from the main menu.

Empty your cart
- Remove all the items from the cart, display message “ Your cart is empty now” then display
the main menu.
- If a user tries to empty the cart before any items added to it, your logic should handle it
gracefully and display exception message “Cart not found” then display the main menu

Checkout

- When the shopper selects this option, your logic must ask the user to enter any coupon
they might have or enter 000 to proceed with a checkout.
- The store offers three types of coupons:
o EEE offers 30% off = electronics
o AAA offers 25% on Apparels
o FFF offers 10% on Food
o If the shopper enters an incorrect coupon, handle it gracefully and display the
exception message “Invalid Coupon” then just proceed with the check out.
o The shopper is allowed to enter only one coupon which get applied on the right
category in the shopper’s cart. If the user enters invalid coupon, they can’t enter
another one just display the error message above and proceed with the check
out.
o If the shopper entered the wrong coupon which discounted no items, example:
cart has electronics and the shopper enters FFF coupon, handle it gracefully and
display the exception message “Invalid Coupon” then just proceed with the
check out.

- Then print out the receipt into a file and name it receipt.log in the same directory as
your code then exit the program at this point.
o receipt.log should have the following format
§ Date:
§ Number of items purchased:
§ List of items purchased,
§ Subtotal:
§ Total Tax:
• If the item is of category
o Electronic category, tax is 8%
o Apparel category, tax is 5%
o Food, no tax
§ Total:

o Example of: receipt.log file

***Welcome to your Java ecommerce shop***
Date: 05/05/2021
Number of items purchased: 4
List of items in a column format 20 char for col width; as follows:





*** Have a nice day***


If the user selects exit store option, your logic will display the message “Have a nice day!” then
just exit the program.

Error handling: Your design should have three custom exceptions used accordingly
- CartNotFoundException: used if a user trying to remove a cart before any items were
added to it and display the message “Cart not found”
- ItemNotFoundException: used if the user is trying to add an item that doesn’t exist in
the catalog or if the user is trying to remove an item that is not in the cart and display
the message “The item is not found”
- InvalidCuponException: used if the user is trying to apply an invalid coupon during check
out and display the message “Invalid Coupon”
- InvalidQuantityExeption: used if the user is trying to add or update a quantity greater to
what’s in the catalog and display the message “The requested quantity is more than
what’s currently available”

Assumption:
- All quantities & prices entered by the user are greater than 0 (don’t validate negative or
non numeric entries )
- Item Id is unique for each entry in the file catalog.txt
- Consider all values in catalog.txt as strings except quantity and price.
- If the user enters any digit that is not listed in the main menu, display the essage “ ivalid
entry” then just display the main menu again
- Copy catalog.txt and paste it in the same package where you have your code.
- The file receipt.log should be stored in the same directory where your code is

Note:
- This is a design problem. You design your classes however you think appropriate in
order to achieve the desired flow of your ecommerce logic.
- There should be a basic structure to your design which consists of
o Ecommerce class with main method.
o ShoppingCart class.
o CatalogItem class.
o Plus you can add any classes you like to complete to design your code.
Rubric
- If any of your classes don’t compile, automatic 0
- Flaws in the ecommerce flow == – 1 points for each flaw identified
- Incorrect use of exception or errors are not handled gracefully == -2 points for each
- -1 point if there is no comments in your code … don’t over comment either, just enough
to share some info about each block of code.
- Don’t include receipt.log I will generate it when I run your code.

Good Luck
Dr. Nassar













































































































§ Number of items purchased:
§ List of items purchased,
§ Subtotal:
§ Total Tax:
• If the item is of category
o Electronic category, tax is 8%
o Apparel category, tax is 5%
o Food, no tax
§ Total:

o Example of: receipt.log file

***Welcome to your Java ecommerce shop***
Date: 05/05/2021
Number of items purchased: 4
List of items in a column format 20 char for col width; as follows:





*** Have a nice day***


If the user selects exit store option, your logic will display the message “Have a nice day!” then
just exit the program.

Error handling: Your design should have three custom exceptions used accordingly
- CartNotFoundException: used if a user trying to remove a cart before any items were
added to it and display the message “Cart not found”
- ItemNotFoundException: used if the user is trying to add an item that doesn’t exist in
the catalog or if the user is trying to remove an item that is not in the cart and display
the message “The item is not found”
- InvalidCuponException: used if the user is trying to apply an invalid coupon during check
out and display the message “Invalid Coupon”
- InvalidQuantityExeption: used if the user is trying to add or update a quantity greater to
what’s in the catalog and display the message “The requested quantity is more than
what’s currently available”

Assumption:
- All quantities & prices entered by the user are greater than 0 (don’t validate negative or
non numeric entries )
- Item Id is unique for each entry in the file catalog.txt
- Consider all values in catalog.txt as strings except quantity and price.
- If the user enters any digit that is not listed in the main menu, display the essage “ ivalid
entry” then just display the main menu again
- Copy catalog.txt and paste it in the same package where you have your code.
- The file receipt.log should be stored in the same directory where your code is

Note:
- This is a design problem. You design your classes however you think appropriate in
order to achieve the desired flow of your ecommerce logic.
- There should be a basic structure to your design which consists of
o Ecommerce class with main method.
o ShoppingCart class.
o CatalogItem class.
o Plus you can add any classes you like to complete to design your code.
Rubric
- If any of your classes don’t compile, automatic 0
- Flaws in the ecommerce flow == – 1 points for each flaw identified
- Incorrect use of exception or errors are not handled gracefully == -2 points for each
- -1 point if there is no comments in your code … don’t over comment either, just enough
to share some info about each block of code.
- Don’t include receipt.log I will generate it when I run your code.

Good Luck
Dr. Nassar

学霸联盟


essay、essay代写