Question: Part A Create a class named Candle for a candle - making business. Include data fields for color ( color ) , height ( height
Part A
Create a class named Candle for a candlemaking business. Include data fields for color color height height and price price Create get methods for all three fields. Create set methods for color and height, but not for price. Instead, when height is set, determine the price as $ per inch.
Part B
Create a child class named ScentedCandle that contains an additional data field named scent and methods to get and set it In the child class, override the parents method that sets the height to set the price of a ScentedCandle object at $ per inch.
Part C
Write an application called DemoCandles that instantiates a Candle object and a ScentedCandle object. Prompt the user for values for each object. For the ScentedCandle, offer the user at least four choices for the scent, such as gardenia, but you do not need to verify that the user enters one of the four choices. Display the details for each Candle.
An example of the program is shown below:
Enter a color for the candle purple Enter a height in a whole number of inches Enter a color for the scented candle orange Enter a height in a whole number of inches Enter a scent. Choose from the following: gardenia, beach, pine, carnation citrus The inch purple candle costs $ The inch citrus orange candle costs $
Task : Created the Candle class.
Task : The Candle class contains the color data field with set and get methods.
Task : The Candle class contains the height data field with set and get methods.
Task : The Candle class contains the price data field and a get method.
Task : Created the ScentedCandle class.
Task : The ScentedCandle class extends the Candle class.
Task : The ScentedCandle class contains the scent data field with get and set methods.
Task : The ScentedCandle price is calculated in the overloaded setHeight method.
Task : Created the DemoCandles class.
Task : The DemoCandles program accepts user input for a Candle and a ScentedCandle object and displays their details.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
