University Project: Theater Lights Simulator Program in Java

Verified

Added on  2022/07/27

|6
|696
|29
Project
AI Summary
This assignment presents a Java-based theater lights simulator program. The program simulates theater lights with user commands to turn lights on and off, including various color combinations. The code is structured into two classes: `Lights.java`, which defines the properties and methods of individual lights (color, on/off state), and `TheaterLights.java`, the main class controlling the program's logic. The `TheaterLights` class includes methods for toggling specific light combinations (red/green, blue/yellow, orange/purple, teal/amber) and a random light toggle function. The `toString` method provides a text-based representation of the lights. The assignment brief outlines project requirements, including planning, a solution overview with a record of tasks and a design overview, development techniques with screenshots, functionality and extensibility assessment, and evaluation based on client feedback. This solution offers a comprehensive understanding of the project's design, implementation, and functionality, demonstrating the practical application of Java programming in simulating theater lighting scenarios.
Document Page
Theater Lights Simulator Program
Java Theater Lights Simulator Program
Student’s Name
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
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.
Document Page
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.
Document Page
Theater Lights Simulator Program
if (randomNum == 0) {
// Turn on red and green lights only
this.toggleRedAndGreen();
} else if (randomNum == 1) {
// Turn on blue and yellow lights only
this.toggleBlueAndYellow();
} else if (randomNum == 2) {
// Turn on orange and purple lights only
this.toggleOrangeAndPurple();
} else if (randomNum == 3) {
// Turn on teal and amber lights only.
this.toggleTealAndAmber();
}
toggleRedAndGreen
This method turns on only the red and green lights.
toggleBlueAndYellow
This method turns on only the blue and yellow lights.
toggleOrangeAndPurple
This method turns on only the orange and purple lights.
toggleTealAndAmber
This method turns on only the teal and amber lights.
switchComplementaryLights(String[] complementaryLights)
This is a private helper method used by the toggle* methods above to switch on their
corresponding lights the lights are complementary to one another.
The method first turns off all other lights and then sets the on states of the
complementary lights to true.
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
Theater Lights Simulator Program
toString
This method prints a string representation of the theater lights in the format.
+---------+
| |
| O |
| |
+---------+
+---------+
| |
| O |
| |
+---------+
+---------+
| |
| O |
| |
+---------+
+---------+
| |
| O |
| |
+---------+
+---------+
| |
| yellow |
| |
+---------+
+---------+
| |
| blue |
| |
+---------+
+---------+
| |
| O |
| |
+---------+
+---------+
| |
| O |
| |
+---------+
Document Page
Theater Lights Simulator Program
main(String[] args)
This executes the given command from the user.
User Input Command Executed
1 Switch on red and green lights (toggleRedAndGreen)
2 Switch on blue and yellow lights (toggleBlueAndYellow)
3 Switch on orange and purple lights (toggleOrangeAndPurple)
4 Switch on teal and amber lights (toggleTealAndAmber)
5 Switch on random lights (toggleRandomLights)
x Terminates the program
chevron_up_icon
1 out of 6
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]