Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

java (do not import anything) ts) All of the followings must be subclasses of the MarketProduct: Write a class Egg derived from the Market Product

java (do not import anything) image text in transcribed
image text in transcribed
ts) All of the followings must be subclasses of the MarketProduct: Write a class Egg derived from the Market Product class. The Egg class has the following private fields: An int indicating the number of eggs. An int indicating the price per dozen of these eggs. Note that the all the prices (throughout the assignment) are indicated in cents. For instance, 450 represents the amount $4.50. The Egg class has also the following public methods: A constructor that takes as input a String with the name of the product, an int indicating the number required, and an int indicating the price of such product by the dozen. The constructor uses the inputs to create a Market Product and initialize the corresponding fields. A get Cost() method that takes no input and returns the cost of the product in cents. The cost is computed base on the number required and the cost per dozen. For instance, 4 large brown eggs at 380 cents/dozen cost 126 cents (the cost should be rounded down to the nearest cent). You may assume that cost of all Market Products fits within an int and therefore doesn't cause overflow, An equals() method which takes as input an Object and return true if input matches this in type, name, cost and number of eggs. Otherwise the method returns false. MarketProduct.java public abstract class MarketProduct { private String name; public MarketProduct(String name) { } /** @return the name * */ public String getName() { return name; } public abstract int getCost(); public abstract boolean equals(Object obj); } Egg.java

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 Machine Performance Modeling Methodologies And Evaluation Strategies Lncs 257

Authors: Francesca Cesarini ,Silvio Salza

1st Edition

3540179429, 978-3540179429

More Books

Students also viewed these Databases questions

Question

Find dy/dx if x = te, y = 2t2 +1

Answered: 1 week ago

Question

How are members held accountable for serving in the assigned roles?

Answered: 1 week ago

Question

Have roles been defined and assigned?

Answered: 1 week ago