Question: You are tasked with writing a program that will keep track of items sold by a retail store. We are now going to add additional

You are tasked with writing a program that will keep track of items sold by a retail store.
We are now going to add additional types of products through the use of inheritance. In addition to the standard Product, there will be a Book and Food class, each with their own unique properties.
We will also need to keep track of the of the inventory or number of specific products available for sale for each item.
Requirements:
If a retail price is not supplied, the retail price should be set to a 20% markup from the wholesale price.
The Food and Book items should inherit all the properties of the Product item
Foods cannot be added to the inventory without an expiration date.
Book will have an author property that should default to "Unknown"
Implement a toString method for Product, Food, and Book.
If the description for an item is not set, do not include it in the toString.
Add a property and methods to track the number of items in inventory for each item.
Negative inventory amounts are not allowed.
Add code to print any items that have an inventory amount less than 5.
Grading details:
Correct usage of OOP concepts (80%)
Correct class design and usage of class instances (25%)
Correct implementation and usage of inheritance(25%)
Other supporting code/logic (30%)
Program runs/correct results (10%)
Formatting/Indentation (10%)
Starter code:
public class RetailInventory {
public static void main(String[] args){
Product computer = new Product("Computer",1800);
computer.setStock(2);
Product Galaxy24= new Product("Samsung S24",800,1199, "Samsung Phone with 256GB memory");
Galaxy24.setStock(8);
Product iPhone15= new Product("iPhone 15 Plus", 999,1499);
iPhone15.setStock(6);
Product headphones = new Product("Wireless Headphones", 178);
headphones.setStock(1);
Product cBook = new Book("Starting out with C++",125.00,150.00, "Tony Gaddis");
cBook.setStock(-1);
Product JavaBook = new Book("Java, Java, Java: Object-Oriented Problem Solving", 10.00);
JavaBook.setStock(5);
Product fujiApples = new Food("Fuji Apples", 3.50, "Mar. 15,2024");
fujiApples.setStock(75);
Product gmCrackers = new Food("Graham Crackers", 4.50, "Apr. 10,2024");
gmCrackers.setStock(21);
Product[] inventory ={computer, iPhone, Galaxy24, headphones, cBook, JavaBook, fujiApples, gmCrackers};
System.out.println("Viewing Store Products:");
System.out.println("-----------------------
");
for (Product item: inventory){
System.out.println(item);
}
System.out.println("Low Stock Levels");
System.out.println("-----------------------
");
//
// Add the code here to print Low Stock Levels
//(items with less then 5 in inventory).
//
}
Sample output:
Error: Starting out with C++- Negative stock levels not allowed.
Viewing Store Products:
-----------------------
Name: Computer, Wholesale: $1,800.00, Retail: $2,160.00, On Hand: 2
Name: iPhone 15 Plus, Wholesale: $999.00, Retail: $1,499.00, On Hand: 6
Name: Samsung S24, Description: Samsung Phone with 256GB memory, Wholesale: $800.00, Retail: $1,199.00, On Hand: 8
Name: Wireless Headphones, Wholesale: $178.00, Retail: $213.60, On Hand: 1
Name: Starting out with C++, Wholesale: $125.00, Retail: $150.00, On Hand: 0, Author: Tony Gaddis
Name: Java, Java, Java: Object-Oriented Problem Solving, Wholesale: $10.00, Retail: $12.00, On Hand: 5, Author: Unknown
Name: Fuji Apple, Wholesale: $3.50, Retail: $4.20, On Hand: 75, Expiration Date: Mar. 15,2024
Name: Graham Crackers, Wholesale: $4.50, Retail: $5.40, On Hand: 21, Expiration Date: Apr. 10,2024
Low Stock Levels
-----------------------
Name: Computer, Wholesale: $1,800.00, Retail: $2,160.00, On Hand: 2
Name: Wireless Headphones, Wholesale: $178.00, Retail: $213.60, On Hand: 1
Name: Starting out with C++, Wholesale: $125.00, Retail: $150.00, On Hand: 0, Author: Tony Gaddis
Process finished with exit code 0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!