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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started