QuestionQuestion

You are tasked with writing a simple program that will keep track of items sold by a retail store. We need to keep track of the stock (or number of specific products available for sale).

Requirements:
• The Food and Book items should inherit all the properties of the Product item in the previous assignment.
• Foods cannot be added to the inventory without an expiration date.
• Implement a toString method for Product, Food, and Book.

Starter code:

public class RetailInventory {
public static void main(String[] args) {
Product computer = new Product("Computer", 1400);
Product iPhone = new Product("iPhone XR", 400, 600);
Product Galaxy10 = new Product("Samsung Galaxy S10", 700, 900, "Phone with 128GB memory.");

Product book = new Book("Starting out with C++", 150.00);

Product apple = new Food("Fuji Apples", 3.50, "Dec. 1, 2019");

Product[] inventory = {computer, iPhone, Galaxy10, book, apple};

System.out.println("Viewing Store Products:");
for (Product item: inventory) {
System.out.println(item);
}
}
}


Sample output:
Viewing Store Products:

name: Computer, description: No description entered., wholesalePrice: $1400.00, retailPrice: $1540.00
name: iPhone XR, description: No description entered., wholesalePrice: $400.00, retailPrice: $440.00
name: Samsung Galaxy S10, description: Phone with 128GB memory., wholesalePrice: $700.00, retailPrice: $770.00
name: Starting out with C++, description: No description entered., wholesalePrice: $150.00, retailPrice: $165.00, author: Author_Placeholder
name: Fuji Apples, description: No description entered., wholesalePrice: $3.50, retailPrice: $3.85, expiration: Dec. 1, 2019

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.

public class Product {

    private String name;
    private String description;
    private double wholesalePrice;
    private double retailPrice;

    /**
    * this constructor initialize name and wholesalePrice
    * and set description to "No description entered."
    * and retailPrice as 10% Percentage from wholesalePrice
    * @param name
    * @param wholesalePrice
    */
    public Product( String name , double wholesalePrice ) {
       this.name = name;
       this.description = "No description entered.";
       this.wholesalePrice = wholesalePrice;
       // calculate retailPrice as 10% Percentage from wholesalePrice
       setRetailPriceByPercentage(10);
    }
   
    /**
    * this constructor initialize name , wholesalePrice and retailPrice
    * and set description to "No description entered."
    * @param name
    * @param wholesalePrice
    * @param retailPrice
    */
    public Product( String name , double wholesalePrice , double retailPrice) {
       this.name = name;
       this.description = "No description entered.";
       this.wholesalePrice = wholesalePrice;
       //this.retailPrice = retailPrice;
       //checkPrice();
       // calculate retailPrice as 10% Percentage from wholesalePrice
       setRetailPriceByPercentage(10);
      
    }
   
    /**
    * this constructor initialize name , wholesalePrice , retailPrice and description
    * @param name
    * @param wholesalePrice
    * @param retailPrice
    * @param description
    */
    public Product( String name , double wholesalePrice , double retailPrice , String description) {
       this.name...

By purchasing this solution you'll be able to access the following files:
Solution.zip.

$13.00
for this solution

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

Find A Tutor

View available Computer Science - Other 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.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
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