So I have spent some time on this....

Write a program named TrafficLightcontroller
Program should have a main method
Construct three TrafficLight objects named:light1,light2,light3
Repeatedly print a menu that allows a user to type in responses and control the three lights.

Menu:
Select traffic light (0 to quit): 1
1)change traffic light 1
2)get current value for traffic light 1
3)set current value for traffic light 1
Enter choice: 2

Traffic light 1 is green

Select traffic light (0 to quit): 3
1)change traffic light 3
2)get current value for traffic light 3
3)set current value for traffic light 3
Enter choice: 1

Traffic light 3 went from yellow to red.

Select traffic light (0 to quit): 2
1)change traffic light 2
2)get current value for traffic light 2
3)set current value for traffic light 2
Enter choice: 3

Traffic light 2 is now green.

1)make traffic light 2 green
2)make traffic light 2 yellow
3)make traffic light 2 red
Enter choice: 3

Traffic light 2 is now green.

Select traffic light (0 to quit): 0

I am confused a bit and lost:

public class TrafficLight {
    private int changeLight;
    private int getLightColor;
    private int setLightColor;
    private int trafficLight1;
    private int trafficLight2;
    private int trafficLight3;
    private int selectLight;
    private int enterChoice;

        public TrafficLight();
            changeLight = 1
            getLightColor=2;
            setLightColor=3;
            trafficLight1=Green;
            trafficLight2=Yellow;
            trafficLight3=Red;
    }
    public static void main (String [] args){
        trafficLight1=new TrafficLight();
        System.out.print("Select traffic light (0 to quit) : ")
        int selectLight=Keyboard.readInt();
            if (selectLight ==1)
                System.out.prinln("1) change traffic light 1")
                System.out.println("2) get current value for traffic light 1")
                System.out.println("3) set current value for traffic light1")
                System.out.print("Enter choice: \n")
                int enterChoice=Keyboard.readInt();

Construct three TrafficLight objects named:light1,light2,light3

this mean

TrafficLight light1 = new TrafficLight();
TrafficLight light2 = new TrafficLight();
TrafficLight light3 = new TrafficLight();

use methods to setColor green,yellow,red ;getColor

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.