class TrafficLight { boolean red, yellow, green; TrafficLight() { this.red = true; this.yellow = false; this.green = false; } //new TrafficLight().change() -> void // To change the lights in the US fashion for this TrafficLight // Note, will modify the booleans red, yellow, and green void change() { // this.red... this.yellow ... this.green ... if (this.red) { this.red = false; this.trafficLight.redOff(); this.green = true; this.trafficLight.greenOn(); } else if (this.yellow) { this.red = true; this.trafficLight.redOn(); this.yellow = false; this.trafficLight.yellowOff(); } else { // In this case, the green light must be the only one on this.green = false; this.trafficLight.greenOff(); this.yellow = true; this.trafficLight.yellowOn(); } } //new TrafficLight().changeBritishStyle() -> void // To change the lights in the British fashion for this TrafficLight // Note, will modify the booleans red, yellow, and green void changeBritishStyle() { // this.red... this.yellow ... this.green ... if (this.red && !this.yellow) { this.yellow = true; } else if (this.red && this.yellow) { this.red = false; this.yellow = false; this.green = true; } else if (this.green && !this.yellow) { this.yellow = true; } else if (this.green && this.yellow) { this.green = false; } else { // In this case, the yellow light must be the only one on this.red = true; this.yellow = false; } } }