Question: Write a class called TrafficLight that extends the Pane class to represent the drawing of a traffic light. The TrafficLight class has three Circle object

Write a class called TrafficLight that extends the Pane class to represent the drawing of a traffic light. The TrafficLight class has three Circle object variables representing the three lights red, yellow, and green of a traffic light. Also, the class includes the definition of an enumerated type, called State, that contains the following identifiers: STOP, CAUTION, and GO. The TrafficLight class constructor creates the geometric structure of the traffic light using three circles within a rectangle. Assume the circle fill color for an OFF light is Grey. Assume the initial state of the traffic light is STOP. Accordingly, the fill colors for the red, yellow, and green circles are set to RED, GREY, and GREY, respectively. The TrafficLight class includes a method, called SwitchState, that accepts a State argument which is used to determine the fill color of the three circles representing the traffic lights. Write a JavaFX application, called TrafficLightDisplayer, that has four fields: A TrafficLight object variable and three Button object variables representing STOP, CAUTION, and GO states. The TrafficLightDisplayer allows the user to control the state of a displayed traffic light by pushing one of the corresponding buttons.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!