Answered step by step
Verified Expert Solution
Question
1 Approved Answer
As it states, please use Java. You are going to develop a Java Class and a Driver that will test the methods within the Class.
As it states, please use Java.
You are going to develop a Java Class and a Driver that will test the methods within the Class. Name the Java Class: Bulb. It will contain the behaviors of a light bulb. Name the Driver Class: Lights. It will test the methods within the Bulb Class. 1. The Bulb Class will include a separate method to perform each of the following A Constructor. The Constructor will initialize the light bulb to False to represent "off when the Bulb Class is instantiated. - A method to turn off the light bulb by setting the bulb to false. - A method to turn on the light bulb by setting the bulb to true . A method that returns the current state of the light bulb (Will retum a True or False) Below is a list of each method name, description, parameter arguments and data type of each parameter argument the method will need, and the return value and data type of the method. Public/Private Return Value and DataMethod Name lype No return value or data Bulb ) ype. Parameters and Data Description Tv None This is the constructor.I will initialize the state of the light bulb to false (Off) Turns the light bulb on by setting the state of the light bulb to true Public Public Void because nothing on() will be returmed. None Public Void because nothing will be returned. off) Turns the light bulb off b setting the state of the light bulb to false Identifies the current status of the light bulb by retuming a true or a false. None. Public Returns a Boolean value status() of true or false to indicate whether the light bulb is on or off None. 2. Create a Driver Class to test Class Bulb. Include the following in the Driver Clas: Instantiate an instance of class Bulb within the Driver. Name this object lightBulb Create a menu in the Driver that allows you to test each of the methods within the class Bulb. Be sure to include each of the following selections in the menu: 1. Tum the light bulb on. 2. Turm the light bulb off. 3. Display the status of the light bulb 4. Exit. Make sure all methods in Class Bulb work by thoroughly testing with the Driver. To test, run the program and use the menu in the Driver to perform the following tasks before submitting Display the status of lightBulb. It should be OFF since your constructor initializes the state to false. Turn the lightBulb on Display the status of lightBulb. Turn the lightBulb off. Display the status of lightBulb. Turn the lightBulb on again. Display the status of the lightBulb. NOTE 1 Do not return any strings to the driver for this assignment. The method that returns the status of the light bulb returns a boolean value. NOTE 2: Do not print the status of the light bulb within the status method. Its only function is to return a true or a false to indicate the status. NOTE 3: The driver should print out a message indicating whether or not the light bulb is on or off based on the boolean value returned by the status method. DO NOT PRINT OUT THE BOOLEAN VALUEStep 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