I was wondering if it was possible for example to create automaticly 2 objects from a class into a new class, and then use a main class create a new object of the new class you just created.
For example:
Public class Trafficlight(){
String color;
public trafficLight(Somecolor){
this.color = Somecolor;
}
}
public class CrossRoad(){
public CrossRoad(){
trafficLight trafficLightNr1 = new trafficLight("green");
trafficLight trafficLightNr2 = new trafficLight("red");
}
}
Public class main
{
public static void main(String[] args) {
CrossRoad SomeCrossRoad = new CrossRoad();
CrossRoad SomeOtherCrossRoad = new CrossRoad();
}
}
Ps: if there are some mistakes in my syntax, i just wrote it fast. I'm just curious if this is possible to create something like this.