Advertisement
Guest User

Untitled

a guest
Oct 18th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. package com.company;
  2.  
  3. public class Semaforo {
  4.  
  5.  
  6. public enum State{On,Off,Change,Flashing, ToString}
  7. private State stato;
  8.  
  9. public Semaforo(){
  10. stato=State.Off;
  11. System.out.println("Rosso");
  12.  
  13.  
  14. }
  15.  
  16. public String ToString(){
  17. String s=" ";
  18.  
  19. }
  20.  
  21. public void On() {
  22. if (stato ==State.On) {
  23. System.out.println("Verde");
  24. }
  25. else if (stato == State.Change) {
  26. System.out.println("Giallo");
  27. }
  28. }
  29.  
  30. public void Off(){
  31. if(stato==State.On)
  32. stato=State.Off;
  33. }
  34.  
  35.  
  36.  
  37. public void Change(){
  38. if(stato==State.On){
  39. System.out.println("rosso");
  40. }
  41. else{
  42. if(stato==State.Off){
  43. System.out.println("spento");
  44. }
  45. }
  46.  
  47.  
  48.  
  49. }
  50.  
  51.  
  52. public void Flashing(){
  53.  
  54.  
  55. }
  56.  
  57.  
  58.  
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement