Theater Lights Simulator Program

Verified

Added on  2022/07/27

|6
|696
|29
AI Summary
Write a JAVa program and report for IB IA assigment Assignment Criterion A: Planning: An appropriate scenario for investigation for an identified client, providing evidence of consultation, is stated. The rationale for choosing the proposed product is partially explained and includes some appropriate criteria for evaluating the success of the product (5-7) in bullet point form. Criterion B: Solution overview • The student must provide a record of tasks and a design overview that includes an outline test plan. • The Record of tasks form must be used. 

Contribute Materials

Your contribution can guide someone’s learning journey. Share your documents today.
Document Page
Theater Lights Simulator Program
Java Theater Lights Simulator Program
Student’s Name

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
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.

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
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
1 out of 6
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]

Your All-in-One AI-Powered Toolkit for Academic Success.

Available 24*7 on WhatsApp / Email

[object Object]