As mentioned in class, we will NOT use the get/set design pattern in this assignment – note the methods listed to be written. You are allowed to use get methods (just not set methods). Your program must be written using Object Oriented Principles (as outlined in the course notes)
Problem Description:
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.
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)
Create one Scanner connected to keyboard in main

Item class:
• Has (private) data members:
o itemCode (int)
o itemName (String)
o itemQuantityInStock (int)
o itemPrice (float)
• Has methods:
o Constructors
o 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
o String toString()
o 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.
o boolean isEqual (Item) returns true if the itemCode of the object being acted on and the item object parameter are the same value
o 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:
o supplierName (String)
• has methods:
o constructor
o boolean addItem (Scanner) – per Item class
o String toString()
ManufacturedItem class – extended from Item class
• has (private) data members:
o itemsUsed – array of 10 ints (to contain the itemCodes)
o numItemsUsed (int)
• has methods:
o constructor
o boolean addItem (Scanner) – per Item class
o String toString()

Inventory class
• Has (private) data members:
o inventory (dynamically allocated array of Item objects)
o numItems (int)
• Has methods:
o Constructors
o 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)
o String toString()
o 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
o 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 array. 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

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

import java.util.Scanner;

* Assignment 1 Main class
public class Assign1Main {

// Method to display menu
public static void displayMenu() {
System.out.println("Enter 1 to add an item to inventory");
System.out.println("2 to display current inventory");
System.out.println("3 buy some of an item");
System.out.println("4 sell some of an item");
System.out.println("5 to quit");

// Main method for program execution
public static void main(String[] args) {
Inventory inventory = new Inventory();
Scanner s = new Scanner(;
String input;
while (true) {
input = s.nextLine();
if (input.equals("1")) {
} else if (input.equals("2")) {
} else if (input.equals("3")) {
if (!inventory.updateQuantity(s, true...

By purchasing this solution you'll be able to access the following files:
Solution.docx, and Solution.xlsx.

50% discount

$50.00 $25.00
for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats