On program start, each inventory item’s data is read from the inventory file, placed in a new item class object, which is then placed in the inventory ArrayList
INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS
- Assignment Details
Model a simple point of sale system that behaves as follows when it is run.
- On program start, each inventory item’s data is read from the inventory file, placed in a new item class object, which is then placed in the inventory ArrayList.
- The user is then presented with a menu of items that can be selected. The user can then chose to
- select an item from the inventory to place in a shopping cart (also an ArrayList).
- The user is presented with a list of available items and makes one selection. The menu of items shown to the user is generated from the ArrayList of inventory
- The item selected is placed in the users cart ArrayList and subtracted from quantity on hand in the inventory ArrayList.
- The user may chose to not select an item to place in the
- take an item out of the cart ArrayList and return it to the inventory ArrayList.
- The user is presented with the contents of the
- The user can select one item to return to the inventory or may chose to keep the contents of the cart “as is”.
- check out, i. e. leave with the items. This triggers
- printing (to the terminal) of a receipt listing the cart. This includes the name and cost of each item, plus the total cost of all items. If there are no items in the cart, a receipt is not printed. I. e. the user just
- emptying of the cart ArrayList after the receipt is
- replacement of the data in the inventory file with the data currently in the inventory
ArrayList. I. e. the inventory file is updated so that it is correct.
- When the user leaves (stops shopping), the next user can elect to shop or halt the
- Assignment Requirements
- You will create the initial inventory text file in order to test your program. (Some example file organizations are shown on the next page.) The inventory file you create for testing your program must
- contain data on at least 5
- be stored in the main folder (directory) of your IntelliJ project. This will allow you to load the file just by using the file’s name instead of a full or relative path) and the file will be included in the ZIP archive that you
- contain three pieces of data for each each inventory item. These are the quantity on hand, the price of the item and the name of the
- You will create the item class. The item class must
- store all the data about an item (quantity on had, price, name) as private fields (data members)
- contain constructors, getters and other methods as necessary, such as to manipulate quantity on hand by adding one or subtracting one.
- not allow a name that is null or of length
- not allow a price that is less than zero.
- not allow the quantity on hand to be less than zero.
- At program start, all items in the inventory file are read and placed in the inventory ArrayList as objects of the item
- The menu of items that can be selected by the user is generated from the item class objects referenced in the inventory ArrayList.
- The user can select one item at a time to place in the cart. The inventory in the ArrayList must be kept up to date as the user selects an item and places it in the cart. The menu must be kept up to date as the user selects an item. I. e. if the quantity on hand becomes zero, the menu should not show that item.
- No item may be placed in a cart if that item has a quantity of zero in the
Some Example File Organizations
Example 1:
item1name item1price item1quantity item2name item2price item2quantity item3name item3price item3quantity
...
Example 2:
item1quantity item1price item1name item2quantity item2price item2name item3quantity item3price item3name
...
Tip: If you data is on separate lines, that a readLine() that follows a nextInt() or a nextDouble() requires a dummy read to absorb the end of line character that exists after an number.
Additional Requirements
- There is no user I/O (input / output) in the item class. All values given to the fields are either initial values or values passed to parametrized constructors. Values of the fields are returned from the class via
- A reference variable and instance object of class util.Scanner must be used to read user input. A reference variable and instance object of class java.util.Scanner must be used to read input from the file. A refernece variable and instance object of class java.io.PrintWriter must be used for all file output.
- Use of try-with-resources is required for all file input and (d)Identifiers must be descriptive, i. e. must self document.
(e)Indention of all code blocks (compound statements, anything in braces), including single statements following selection or while statements, is required.
Attachments:
Expert's Answer
1219 Times Downloaded
Related Questions
. Introgramming & Unix Fall 2018, CRN 44882, Oakland University Homework Assignment 6 - Using Arrays and Functions in C
DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma
. The standard path finding involves finding the (shortest) path from an origin to a destination, typically on a map. This is an
Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t
. Develop a program to emulate a purchase transaction at a retail store. This program will have two classes, a LineItem class and a Transaction class. The LineItem class will represent an individual
Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th
. SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:
1
Project 1
Introduction - the SeaPort Project series
For this set of projects for the course, we wish to simulate some of the aspects of a number of
. Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:
1
Project 2
Introduction - the SeaPort Project series
For this set of projects for the course, we wish to simulate some of the aspects of a number of