Java Programming
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.
Related Questions
. The fundamental operations of create, read, update, and delete (CRUD) in either Python or Java
CS 340 Milestone One Guidelines and Rubric
Overview: For this assignment, you will implement the fundamental operations of create, read, update,
. 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
Retail Transaction Programming Project
Project Requirements:
Develop a program to emulate a purchase transaction at a retail store. This
. The following program contains five errors. Identify the errors and fix them
7COM1028
Secure Systems Programming
Referral Coursework: Secure
. Accepts the following from a user: Item Name Item Quantity Item Price Allows the user to create a file to store the sales receipt contents
Create a GUI program that:Accepts the following from a user:Item NameItem QuantityItem PriceAllows the user to create a file to store the sales receip
. The final project will encompass developing a web service using a software stack and implementing an industry-standard interface. Regardless of whether you choose to pursue application development goals as a pure developer or as a software engineer
CS 340 Final Project Guidelines and Rubric
Overview The final project will encompass developing a web service using a software stack and impleme