Question: Problem #3: Lamps (40 Points) For this problem, you will be creating a derived class, base class and an interface. No Driver is required, but

Problem #3: Lamps (40 Points)

For this problem, you will be creating a derived class, base class and an interface. No Driver is required, but I have attached one to test with. A UML diagram for this problem has been provided to assist you.

Lamp Class:

Attribute:

Color of light emitted by Lamp

Methods:

get and set methods for attribute

toString(): returns a String describing the Lamp

constructor that takes in the Lamp's color of light

------------------------------------------------------------------

Flammable Interface: Flammable should be its own interface which has a:

Method header:

boolean startOnFire(): returns if the lamp has started on fire. Returns true if the lamp is on fire, false otherwise.

------------------------------------------------------------------

LavaLamp: LavaLamp should be its own class and should inherit from Lamp and implement Flammable. LavaLamp should have:

Attributes:

number of color blobs

Methods:

get and set methods for attribute

toString(): returns a String describing the LavaLamp

constructor which takes in the LavaLamp's light color

constructor which takes in the LavaLamp's light color and the number of color blobs in the LavaLamp

Flammable() returns true 3% of the time (must use Random object to generate this)

Grading Breakdown:

10 -- Correctly creating your Interface

10 -- Correctly creating your Base Object

10 -- Correctly creating your Derived Object

10 -- Correctly connecting your data using the correct keywords, etc.

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!