Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- public class Semaforo {
- public enum State{On,Off,Change,Flashing, ToString}
- private State stato;
- public Semaforo(){
- stato=State.Off;
- System.out.println("Rosso");
- }
- public String ToString(){
- String s=" ";
- }
- public void On() {
- if (stato ==State.On) {
- System.out.println("Verde");
- }
- else if (stato == State.Change) {
- System.out.println("Giallo");
- }
- }
- public void Off(){
- if(stato==State.On)
- stato=State.Off;
- }
- public void Change(){
- if(stato==State.On){
- System.out.println("rosso");
- }
- else{
- if(stato==State.Off){
- System.out.println("spento");
- }
- }
- }
- public void Flashing(){
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement