The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Jul 2017 |
| Last Sign in: | 304 Weeks Ago, 1 Day Ago |
| Questions Answered: | 15833 |
| Tutorials Posted: | 15827 |
MBA,PHD, Juris Doctor
Strayer,Devery,Harvard University
Mar-1995 - Mar-2002
Manager Planning
WalMart
Mar-2001 - Feb-2009
Hi, I need to get this assignment done for my Business Application Development Class by tonight.
The Language is Java, I have attached the assignment on here for you to see.
Â
In this assignment you will model a home automation light controller that can turn on and off individual lights in a building. The controller will be an object that will have public methods to control the lights. The lights will in turn also be objects created from the Light class. A simple driver program will demonstrate the use cases of the controller.
Â
1) Create a new Project. Add new class files for Light and Controller.
Â
2) Light class: a) private attribute boolean isOn b) private attribute boolean isDefective c) private attribute int brightness d) private attribute double defectRate e) a default constructor that will i) set brightness to 255, turn light off and set defective to off ii) generate a random number between .05 and .15 and assign it to defectRate Hint: use Random's nextDouble() method that returns a number from 0.0 to 1.0. Get this number to the desired range of .05 to .15 by dividing it by 10 and adding an offset of .05. f) private method boolean isBurningOut() that simulates the probability of the light burning out when turning on. It should return true if the light is already defective. Otherwise it should generate a random number from 0.0 to 1.0 (with nextDouble()) and compare it to the defectRate. If the random number is less than defectRate, the light will burn out, so the method should return true. Otherwise it should return false. g) public method void turnOn() that attempts to turn on the light. It should check with the isBurningOut() method and then set the light's isOn to true if it is not burning out, otherwise, it should turn the light off and mark it as defective. h) public method void turnOff() that turns the light off. i) public method void setBrightness(int desiredBrightness) that checks the parameter for being in allowable range and sets the light brightness to the desired value. If the parameter is less than 0 or more than 255, set it to 0 or 255, respectively. j) public method char getStatus() that returns a character 'o' if the light is on with brightness less than 128, 'O' if it is on with brightness 128 or more, and dot '.' if the light is off.
Â
3) Controller class: a) private array Light[] lights that holds the references to light objects b) a constructor that takes one parameter numLights that indicates how many lights are controlled by the controller i) it dimensions the lights array to size numLights ii) it creates new lights objects and stores them in the lights array (use a for loop) c) public method void printStatus() that goes through the lights array and prints the status of each light on one line. Afterwards it prints a newline to move the printing position to the next line. d) public method void turnLightOn(int lightid) that turns on the indicated light and calls printStatus() e) public method void turnLightOff(int lightid) that turns off the indicated light and calls printStatus() f) public method void setLightBrightness (int lightid, int intensity) that sets the brightness of the indicated light to the desired intensity and calls printStatus() g) public method void turnAllOn() that turns all the lights on and calls printStatus() h) public method void turnAllOff() that turns all the lights off and calls printStatus() i)
Â
4) Driver program: a) Instantiate one controller object with 20 lights. b) perform the operations as described in the Requirements section.
----------- Â ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly