write in java program

Objective: develop a program to simulate the control of traffic lights at an intersection using static methods.
Problem statement: design a system that manages the traffic lights at a four-way intersection, cycling through the different light phases(green,yellow,red).
Requirements:
Handle light phrases:
-create individual static methods for each phase: redLight(), yellowLight(), greenLight().
-Define rules for transitioning between phases, ensuring proper sequencing.
Timing system:
-implement static methods to manage time intervals, such as setGreenTime(int seconds).
-Include safety checks to prevent unrealistic timing.
Text-based visualization:
-use a static method to print the current state of the intersection with ASCII art or a simple text representation.
User interaction:
implement a menu system through static methods allowing users to manually control lights or change timings.
-include validation to ensure user input adheres to traffic regulations.

Sample output:
Welcome to the traffic light controller!
Choose a traffic light phase:
1. Green light
2. Yellow light
3. Red light
4. Exit
1
Intersection Status: Green light
Choose a traffic light phase:
1. Green light
2. Yellow light
3. Red light
4. Exit
2
Intersection Status: Yellow light
Choose a traffic light phase:
1. Green light
2. Yellow light
3. Red light
4. Exit
3
Intersection Status: Red light
Choose a traffic light phase:
1. Green light
2. Yellow light
3. Red light
4. Exit
4
Exiting Traffic Light Controller.

Below is a Java program to simulate control of traffic lights at an intersection as per your requirements.

```java
import java.util.Scanner;

public class TrafficLightController {

// Timing for each light phase in seconds
private static int greenTime = 60;
private static int yellowTime = 5;
private static int redTime = 60;

public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int choice;

// Display welcome message
System.out.println("Welcome to the traffic light controller!");

do {
// Display menu options
System.out.println("Choose a traffic light phase:");
System.out.println("1. Green light");
System.out.println("2. Yellow light");
System.out.println("3. Red light");
System.out.println("4. Change green time");
System.out.println("5. Exit");

// Get user input
choice = scanner.nextInt();

// Handle traffic light phase choice
switch (choice) {
case 1:
greenLight();
break;
case 2:
yellowLight();
break;
case 3:
redLight();
break;
case 4:
System.out.print("Enter new green time in seconds: ");
int newGreenTime = scanner.nextInt();
setGreenTime(newGreenTime);
break;
case 5:
// Exiting message will be handled after the switch
break;
default:
System.out.println("Invalid choice. Please try again.");
}
} while (choice != 5);

System.out.println("Exiting Traffic Light Controller.");
scanner.close();
}

public static void greenLight() {
System.out.println("Intersection Status: Green light");
printLight("green");
// Here you can simulate the wait using Thread.sleep(greenTime * 1000)
}

public static void yellowLight() {
System.out.println("Intersection Status: Yellow light");
printLight("yellow");
// Here you can simulate the wait using Thread.sleep(yellowTime * 1000)
}

public static void redLight() {
System.out.println("Intersection Status: Red light");
printLight("red");
// Here you can simulate the wait using Thread.sleep(redTime * 1000)
}

public static void setGreenTime(int seconds) {
if (seconds < 0) {
System.out.println("Timing cannot be negative. Please enter a positive value.");
} else {
greenTime = seconds;
System.out.println("Green time updated to " + greenTime + " seconds.");
}
}

// ASCII art or a simple text representation
public static void printLight(String color) {
System.out.println(" | |");
System.out.println(color.equalsIgnoreCase("red") ? " R | |" : " | |");
System.out.println(color.equalsIgnoreCase("yellow") ? " | Y |" : " | |");
System.out.println(color.equalsIgnoreCase("green") ? " | | G" : " | |");
System.out.println(" | |");
}
}
```

This program provides a simple interface for controlling traffic lights through a console menu system. It does not simulate the automatic cycling of lights or the execution of the time delays for the light phases, as these would prevent further interaction with the user without parallel programming techniques. To simulate the timing, one could use `Thread.sleep(milliseconds)`, but that would require additional logic to be able to interrupt the sleep if user interaction is desired during the sleep period.