You are on page 1of 2

Computer Engineering Department

Lab Assignment 4
2020 – 2021 Fall, CMPE 211 Fundamentals of Programming II

INVENTORY PROGRAM

DUE DATE: 11.10.2020 – 23:59

This week we will build a simple sale management system. The program will keep
track of what products are available to sale and which products are stocked in the physical
(make‐believe) store. Further functionality will be announced on the lab hour so please
bring the groundwork. We will work with an interface; StockInterface. The file is available
on our Moodle course page and you should start by downloading it. Please do not change
the interface since you will not submit it. The file is already included in the VPL. There is
also the screencast demo to get an idea about the lab.

PRODUCT CLASS
The product class represents the arbitrary products that are available to the world.

Implementation Details

Product class has the following instance variables;

• int productNo the identifier of the product. Should be handled using a static class variable
that starts at 1 and increments sequentially.

• String name

• String type

• int cost

The Product objects are instantiated with the name, type and the cost fields.

For the purposes of the prelab, just a toString method is needed, the format is as follows;

Product #<productNo>: <name> (<type>) <cost>$

1
Computer Engineering Department

GROCERY CLASS
The Grocery class implements the StockInterface.

Implementation Details

• Product product the template product that is stocked by the Grocery object.

• int price the retail price of the item

• int amount the amount left in the stock

The constructor of the Grocery class should get the product, price and the amount. If the
item is set to sold less than the cost of the item, warn the user and carry on as normal;

Warning, sale price is lower than product cost

INVENTORYPROGRAM MAIN CLASS


The main method should be in InventoryProgram.java.

The commands you need to support this week are;

• np new product, create a new product and append to your list.

• ns new stock(grocery) item, create a new stock item (using an existing product) and append
to your list.

• lp list products, find those in the correct list.

• ls list stock items, like above, there’s no rule against multiple stock items using the same
product.

• q quit, but print out all the stock items before exiting.

You might also like