Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

-----------------------------------------------MERCHANDISE.JAVA----------------------------------------------- /** DO NOT EDIT THIS CLASS * * @author murrayg * A class representing an item to be sold in a store. * */

image text in transcribedimage text in transcribed

image text in transcribed

-----------------------------------------------MERCHANDISE.JAVA-----------------------------------------------

/** DO NOT EDIT THIS CLASS

*

* @author murrayg

* A class representing an item to be sold in a store.

*

*/

public abstract class Merchandise

{

// Every merchandise item has a price and a brand/manufacturer.

private double price;

private String brand;

/**

*

* @param price: the price of the item

* @param brand: the brand of the item

*/

public Merchandise(double price, String brand)

{

this.price = price;

this.brand = brand;

}

/**

*

* @return the price of the item

*/

public double getPrice()

{

return price;

}

/**

*

* @return the brand of the item

*/

public String getBrand()

{

return brand;

}

/**

*

* @param price: the price of the item

*/

public void setPrice(double price)

{

this.price = price;

}

/**

*

* @param brand: the brand of the item

*/

public void setBrand(String brand)

{

this.brand = brand;

}

/**

*

* @return a String representing a sales pitch for the item

* (to be used in ads)

* e.g. "Milk is good for your bones!"

* This must be implemented for any subclass if it is to be instantiated.

*/

public abstract String getSalesPitch();

}

-----------------------------------------------PERISHABLE.JAVA-----------------------------------------------

/**

* DO NOT EDIT THIS INTERFACE.

*

* An interface to be used by classes representing perishable items.

* @author murrayg

*

*/

public interface Perishable

{

/**

*

* @return a String representing the expiry date

* (for simplicity, just represent an expiry as "mm/dd/yyyy")

*/

public String getExpiryDate();

}

Assignment 3: Interfaces & Abstract Classes Overview: In this assignment you are given an abstract class and an interface and asked to define two new classes that extend the abstract class and/or implement the interface. You will then write a third class that uses (aggregates) the first classes you created. A. Managing Store Inventory You want to write software that will make it easier for small business owners to manage their inventory. You are given an abstract class and an interface to work with. You should look at them now Merchandise this is an abstract class encapsulating information about items to be sold in a store. Anything that is sold in a store will be an object of a subclass of Merchandise. Because Merchandise is abstract, you cannot directly instantiate it (create objects of it). It contains one abstract method that must be implemented by any subclass if that subclass is to be instantiated: @return a String representing a sales pitch for the item (to be used in ads) e.g. "Milk is good for your bones!" This must be implemented for any subclass if it is to be instantiated public abstract String getSalesPitch); Perishable - this is an interface that classes can implement if they represent perishable items (items that go bad after a certain point). It contains only one abstract method: @return a String representing the expiry date (for simplicity, just represent an expiry as "mm/ddlyyyy") public String getExpiryDate) You should not modify the Merchandise class or the Perishable interface. Assignment 3: Interfaces & Abstract Classes Overview: In this assignment you are given an abstract class and an interface and asked to define two new classes that extend the abstract class and/or implement the interface. You will then write a third class that uses (aggregates) the first classes you created. A. Managing Store Inventory You want to write software that will make it easier for small business owners to manage their inventory. You are given an abstract class and an interface to work with. You should look at them now Merchandise this is an abstract class encapsulating information about items to be sold in a store. Anything that is sold in a store will be an object of a subclass of Merchandise. Because Merchandise is abstract, you cannot directly instantiate it (create objects of it). It contains one abstract method that must be implemented by any subclass if that subclass is to be instantiated: @return a String representing a sales pitch for the item (to be used in ads) e.g. "Milk is good for your bones!" This must be implemented for any subclass if it is to be instantiated public abstract String getSalesPitch); Perishable - this is an interface that classes can implement if they represent perishable items (items that go bad after a certain point). It contains only one abstract method: @return a String representing the expiry date (for simplicity, just represent an expiry as "mm/ddlyyyy") public String getExpiryDate) You should not modify the Merchandise class or the Perishable interface

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Marketing The New Profit Frontier

Authors: Ed Burnett

1st Edition

0964535629, 978-0964535626

More Books

Students also viewed these Databases questions