Computers and Technology, 02.03.2021 01:00 iheartlink1
Write a JAVA program that simulates a circuit for controlling a hallway light that has switches at both ends of the hallway. Each switch can be up or down, and the light can be on or off. Toggling each switch turns the light on or off. (This is called a 3-way switch).
Create a class called ThreeWaySwitch which simulates this situation. Provide two instance variables for the states of the two switches at each end of the hallway:
private int firstSwitchState = 0,
secondSwitchState= 0 ;
Provide a constructor with the following heading:
public ThreeWaySwitch(int initialFirstSwitch,
int initialSecondSwitch)
and the following methods:
public int getFirstSwitchState() // 0 = down, 1 = up
public int getSecondSwitchState()
public int getLightState() // 0 = off, 1 = on
public void toggleFirstSwitch()
public void toggleSecondSwitch()
Do not:
provide a third instance variable for the light's state (on or off)
use the ternary operator '?', or any if or switch statements in this class
instead use the '+' and '%' operators (hint: (1 + 1) % 2 = 0)
Write a class named CircuitTester that tests all four switch combinations, printing the status of the two switches and the light for each combination of switches (down/down, up/down, down/up, and up/up).
Answers: 2
Computers and Technology, 22.06.2019 15:00
I'm taking a class on how to make a movie, and it offers some apps that would be in the process. the thing is, i don't have any of those ha. if you have any tips on some apps i could use, that would be awesome. i don't have an iphone, so don't suggest any apps like imovie. i know that this is a weird question, but it would be super for me. : )
Answers: 2
Computers and Technology, 22.06.2019 15:20
The north and south regions had very diferent economies in the 1800s.
Answers: 1
Computers and Technology, 23.06.2019 01:10
Are special combinations of keys that tell a computer to perform a command. keypads multi-keys combinations shortcuts
Answers: 1
Computers and Technology, 23.06.2019 23:40
4. what is the reason for including the following code snippet in the header file animal.h? #ifndef animal_h #define animal_h class animal { public: animal(); animal(double new_area_hunt); void birth(); void hunt(double new_area_hunt); void death(); double get_area_hunt() const; private: double area_hunt; }; #endif
Answers: 3
Write a JAVA program that simulates a circuit for controlling a hallway light that has switches at b...
Mathematics, 15.04.2020 19:10
English, 15.04.2020 19:10
Biology, 15.04.2020 19:10
Biology, 15.04.2020 19:10
Social Studies, 15.04.2020 19:10
Law, 15.04.2020 19:10
English, 15.04.2020 19:11
Mathematics, 15.04.2020 19:11