logo

Theater Lights Simulator Program

   

Added on  2022-07-27

6 Pages696 Words29 Views
 | 
 | 
 | 
Theater Lights Simulator Program
Java Theater Lights Simulator Program
Student’s Name
Theater Lights Simulator Program_1

Theater Lights Simulator Program
Abstract
The Theater Lights Simulator program is a simple text based program that aims to
simulate the working of theater lights. The program has multiple lights that turn on
and off based on user commands.
Theater Lights Simulator Program_2

Theater Lights Simulator Program
Coding and Design.
Lights.java
This is a simple class that implements the basic properties of a light such as its color
and its state (whether it is on/off).
The properties isOn and color represent the on state and the color of the light
respectively.
The method switchOn allow the user to switch the light to on state and the method
switchOff allow the user to switch the light to off state.
The method toString prints a string representation of the light that is as follows based
on the on state or off state of the light and its color:
a) Light is off:
+---------+
| |
| O |
| |
+---------+
b) Light is on:
+---------+
| |
| blue |
| |
+---------+
TheaterLights.java
This is the main class that controls the working of the lights. It contains various
methods for controlling the working of the lights.
The property lights stores an array of lights which are instances of the Light class.
toggleRandomLights
This method chooses an random integer between 0 and 4(exclusive) and then from the
chosen number chooses which lights will light.
Theater Lights Simulator Program_3

End of preview

Want to access all the pages? Upload your documents or become a member.