MIS223 – Java Programming
Assignment 1 – “Cart” OOP Application Spring Semester – 2022
Subject: Console OOP application Type: Uncontrolled
In this assignment you are required to produce a Java code which simulates a checking out process at CUEB Supermarket.
This is an object-oriented application so you have to create a number of classes that will be used in your application.
There are four classes that represent goods' types:
Beverage
Food
Stationery
EverydayNeeds
All this classes implement Goods interface that is given to you: public interface Goods{
public double getPrice();
public String getDescription();
public void setUsed(boolean state);
public boolean getUsed();
}
As it follows from the interface above classes have at least two fields: price and description (e.g. type of food or brand name). You have to write the code for the classes.
One more class is a CheckOut class that represents the object you have to “buy”. The class contains at least four fields (other objects): Beverage, Food, Stationery, and EverydayNeeds. Only completed Cart object may have price. You have to write the code for the class.
And finally a Cart class that represent the supermarket and is used to test the “checking out”. It contains all parts available at the supermarket and all methods to display menus, get user input, display results etc.
You have to finish the code for the Cart class. It should work as next.
1. When you run your application the following menu is displayed:
2. If you select “1” from the menu you may shop on beverage. Select a good:
After you have selected a good, you are going to decide how many of the selected good you want to buy:
3. After decided how many you want to buy, the Beverage Menu will be displayed for continue shopping on beverage:
You can repeat the step 2 & 3 for several times.
4. After you selected option 6 from the Beverage Menu, the Main Menu will displayed:
5. Now if you want to buy more goods (such as Food, Stationery or Everyday Needs), you can repeat step 3 to step 4.
6. When you want to check out, you can select option 5 from the Main Menu:
The Main menu will show up after the Cart list.
7. You can choose option 6 from the Main Menu to exit the system:
Notice that the goods already in cart is still displayed! If you select new one the previous one should be available next time.
If your cart is empty, selecting “Check Out” option causes next message: “You haven’t selected any goods. Please shop now!”
All errors and exceptions should be handled. If user enters wrong number (not in menu) or any other wrong information he/she has to be warned. The application shouldn’t crash because of wrong input.
Note:
For your assignment you have to submit an entire application with all the functionality a described above. It includes all classes (code) you have written.