[Solved] CST8130 Assignment1- Inventory System

$25

File Name: CST8130_Assignment1-_Inventory_System.zip
File Size: 348.54 KB

SKU: [Solved] CST8130 Assignment1- Inventory System Category: Tag:
5/5 - (1 vote)

In this assignment, you will write efficient Java code to create a basic inventory system using a dynamically allocated data structure to hold the inventory and another dynamically allocated array to hold a record of transactions. Your code must handle every single possible condition. The inventory system will contain two types of items items that are purchased from a supplier; and items that our company manufactures which contains items purchased. Our program will run with a basic menu that allows the user to add an item to inventory, display to the screen the inventory, buy an item (ie add to the quantity of that item) and sell an item (ie subtract from the quantity of that item). You are allowed to buy and sell any item (purchased or manufactured) in the inventory.

Note You are welcome to add to the assignment, but I am trying to bound the scope of the assignment so that you do not have too much work. Assume that all string field input does not contain spaces which will make the input easier.

Hint: This assignment needs to be tackled in a structured fashion in order for it to be finished quickly. Do not write more than 20-30 lines of code at a time without running your program. I will be discussing structured strategies in class. Enjoy!!

The following is a suggestion of how to structure the code (you may make changes, but they must follow Object-Oriented Principles as discussed in class)

Item class:

  • Has (private) data members:
    • itemCode (int)
    • itemName (String)
    • itemQuantityInStock (int)
    • itemPrice (float)
  • Has methods:
    • Constructors
    • boolean addItem (Scanner) reads from the Scanner object passed in and fills the data member fields with valid data; method returns true if successfully reads in all fields else returns false
    • String toString()
    • boolean updateItem (int amount) updates the quantity field by amount (note amount could be positive or negative) returns true if successful else false Note- quantityInStock field can never be less than 0.
    • boolean isEqual (Item) returns true if the itemCode of the object being acted on and the item object parameter are the same value
    • boolean inputCode(Scanner) reads a valid itemCode from the Scanner object and returns true/false if successful

NOTE: because the data members are all private in the Item class, only this class can access them. So If you need to do something to any of these data members, you must write a method to do it (for example methods isEqual, inputCode)

PurchasedItem class extended from Item class

  • has (private) data members:
    • supplierName (String)
  • has methods:
    • constructor
    • boolean addItem (Scanner) per Item class
    • String toString()

ManufacturedItem class extended from Item class

  • has (private) data members:
    • itemsUsed array of 10 ints (to contain the itemCodes)
    • numItemsUsed (int)
  • has methods:
    • constructor
    • boolean addItem (Scanner) per Item class
    • String toString()

Inventory class

  • Has (private) data members:
    • inventory (dynamically allocated array of Item objects)
    • numItems (int)
  • Has methods:
    • Constructors
    • boolean addItem (Scanner) adds an item to the inventory array (uses polymorphism to call addItem method in the correct derived Item class for input of the fields of the Item)
    • String toString()
    • int alreadyExists (Item) returns the index of an Item in the inventory array with the same itemCode as the Item object in the parameter list, else returns -1
    • boolean updateQuantity (Scanner, boolean) reads in an itemCode to update and quantity to update by and updates that item by the input quantity in the inventory The boolean parameter is used to denote whether buying operation or selling operation is occurring. Method returns true/false on whether update was successful or not

Assign1Main class

  • Has methods:
    • main menu processing

Sample Output: green is user input

Enter 1 to add an item to inventory

2 to display current inventory

3 buy some of an item

4 sell some of an item

5 to quit

1

Do you wish to add a purchased item (enter P/p) or manufactured (enter anything else)? p

Enter the code for the item: 123

Enter the name for the item: paper

Enter the quantity for the item: 100

Enter the price of the item: 0.50

Enter the name of the supplier:

Staples

Enter 1 to add an item to inventory

2 to display current inventory

3 buy some of an item

4 sell some of an item

5 to quit

1

Do you wish to add a purchased item (enter P/p) or manufactured (enter anything else)? P

Enter the code for the item: ab

Invalid codeplease enter integer greater than 0

Enter the code for the item: 234

Enter the name for the item: nails

Enter the quantity for the item: a

Invalid quantityplease enter integer greater than 0

Enter the quantity for the item: -5

Invalid quantityplease enter integer greater than 0

Enter the quantity for the item: 5000

Enter the price of the item: a

Invalid priceplease enter float greater than 0

Enter the price of the item: -2

Invalid priceplease enter float greater than 0

Enter the price of the item: 2.00

Enter the name of the supplier:

ABConstruction

Enter 1 to add an item to inventory

2 to display current inventory

3 buy some of an item

4 sell some of an item

5 to quit

1

Do you wish to add a purchased item (enter P/p) or manufactured (enter anything else)? m

Enter the code for the item: 444

Enter the name for the item: Instructions

Enter the quantity for the item: 25

Enter the price of the item: 1.00

Enter up to 10 codes used in this item (-1 to quit):

123

-1

Enter 1 to add an item to inventory

2 to display current inventory

3 buy some of an item

4 sell some of an item

5 to quit

2

Inventory:

Item: 123 paper 100 price: $0.5 Supplier: Staples

Item: 234 nails 5000 price: $2.0 Supplier: ABConstruction

Item: 444 Instructions 25 price: $1.0 Codes used: 123,

Enter 1 to add an item to inventory

2 to display current inventory

3 buy some of an item

4 sell some of an item

5 to quit

3

Enter valid item code: 456

Code not found in inventory

Errorcould not buy item

Enter 1 to add an item to inventory

2 to display current inventory

3 buy some of an item

4 sell some of an item

5 to quit

3

Enter valid item code: 444

Enter valid quantity : 5

Enter 1 to add an item to inventory

2 to display current inventory

3 buy some of an item

4 sell some of an item

5 to quit

4

Enter valid item code: 123

Enter valid quantity : 50000

Error could not sell item

Enter 1 to add an item to inventory

2 to display current inventory

3 buy some of an item

4 sell some of an item

5 to quit

2

Inventory:

Item: 123 paper 100 price: $0.5 Supplier: Staples

Item: 234 nails 5000 price: $2.0 Supplier: ABConstruction

Item: 444 Instructions 30 price: $1.0 Codes used: 123,

Enter 1 to add an item to inventory

2 to display current inventory

3 buy some of an item

4 sell some of an item

5 to quit

4

Enter valid item code: 123

Enter valid quantity : 9

Enter 1 to add an item to inventory

2 to display current inventory

3 buy some of an item

4 sell some of an item

5 to quit

2

Inventory:

Item: 123 paper 91 price: $0.5 Supplier: Staples

Item: 234 nails 5000 price: $2.0 Supplier: ABConstruction

Item: 444 Instructions 30 price: $1.0 Codes used: 123,

Submission:

You must submit to the assignment link in Blackboard by the due date and time a zip file (named LastnameFirstNameAssign1) containing:

  • all source code ie .java files (Note I will re-compile and run your program.so all code must be available to me and MUST not be in a package) with headers. (Headers should contain name, student number, assignment number, date, purpose of class, brief description of each data member and method
  • Your test plan in either .docx or .xls format

Failure to provide any of the above will have an effect on your grade for this assignment. Marking guide will be published shortly.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] CST8130 Assignment1- Inventory System
$25