Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a Java program that simulates a simple online shopping system. It has 4 pa

ID: 659634 • Letter: W

Question

Write a Java program that simulates a simple online shopping system. It has 4 part of the pragram:

(a) Using the UML diagram above as a guide, design and implement a set of classes that define various types of reading material. These classes model reading material one would purchase. Include data values that describe various attributes of the material.

Class files to be created:

ReadingMatter has three instance variables: title (type String), ISBN (type String of 13 characters) and price (type double). Include a constructor and get and set methods for these three instance variables. The class also has a toString( ) method to return a description of the reading matter.


Magazine includes an extra instance variable: editor (type String) with get and set methods for it. Also override toString( ) and content( ) methods to include Magazine?s editor details.

Book includes an extra instance variable: author (type ArrayList) with get and set methods for it. There may be more than one author so allow their names to be stored in an ArrayList. Also override toString( ) method to include Book?s author details.

TextBook includes extra instance variable answers (type boolean) with get and set methods for it. Also override toString( ) method to include TextBook details.


Novel includes extra instance variable characters (type ArrayList) with get and set methods for it. Also override toString( ) method to include all characters in the Novel.

(b) Populate the online shopping system with at least FOUR entries from each category, e.g., BOOK, MAGAZINE, TEXTBOOK, NOVEL. At the start of your program, you should read in a text file with the required information. The format of the text file will be:

BOOK
TITLE: ?This is book a?
ISBN: ?5978230012546?
PRICE: 56.99
AUTHOR: John Denon

MAGAZINE
TITLE: ?News?
ISBN: ?1154462600125?
PRICE: 7.50
EDITOR: "Stuart, Lagoon"

TEXTBOOK
TITLE: ?Java text book?
ISBN:?9699563285452?
PRICE: 159
AUTHOR: ?Dan, Newman?, ?Adam, Sandstone"
ANSWERS: true

NOVEL
TITLE: ?A Road To The Village?
ISBN: ?549556897K?
PRICE: 22.99
AUTHOR: ?Daniell, K.P.?
CHARACTERS: ?Ron Jerrard?, ?Billy Sun?, ?Sandra Newman?

Note: The words BOOK, MAGAZINE, TEXTBOOK, and NOVEL are always presented in capital letters. There is always a blank line between entries in the file. TITLE, ISBN, PRICE, AUTHOR ANSWERS, and EDITOR are always capitalised. After one of these words will be a ?:?, followed by a blank space followed by the required data.

(c) Define a class ShoppingCart that emulates a shopping cart. Define a method addToCart( ) to add reading materials to the cart and update the total price instance variable. Note the buyer is able to select from a list of reading material from each category. Also define a toString( ) method which returns the contents of the cart together with the summary information of the items in it.

Create a main driver class entitled CheckOut that should have a loop to continue as long as the user wants to shop. After selecting the menu item the program should prompt the user to add reading material details. When the user finishes shopping, print the cart contents and ?Please pay?..? message with the total price of the items in the cart.

(d) After a sale is completed, update a sales file (entitle: salesFile.txt) with the total purchase price from each of the four categories, as well as the date of the last sale. For example, if the file originally contains:

2009-09-09
BOOK: 1123.90
MAGAZINE: 145.67
TEXTBOOK: 2634.60
NOVEL: 573.20

And another sale was completed on 2009-09-10 for a novel costing $21.90, the file would now show:

2009-09-10
BOOK: 1123.90
MAGAZINE: 145.67
TEXTBOOK: 2634.60
NOVEL: 595.10

It should be possible to retrieve the information from the salesFile just prior to exiting the program.

*********************************************************************************************

Please include screenshots of the program output if you want to answere, thanks.

ReadingMatter Book Magazine TextBook Novel

Explanation / Answer

ShoppingCart.java

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote