foozar

JSP_BulbGame_BulbClass

Nov 13th, 2019
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. package it.cefi.models;
  2.  
  3. public class Lampadina {
  4.  
  5. private static Lampadina instance;
  6.  
  7. private Lampadina() {
  8.  
  9. }
  10.  
  11. public static synchronized Lampadina getInstance() {
  12.  
  13. if (instance == null) {
  14. instance = new Lampadina();
  15. }
  16.  
  17. return instance;
  18. }
  19.  
  20. public bulbState state = bulbState.OFF;
  21.  
  22. public int count = 0;
  23.  
  24. public void click() {
  25.  
  26. if (count > 9) {
  27. state = bulbState.BROKEN;
  28. count = 9;
  29. } else {
  30. if (state == bulbState.OFF)
  31. state = bulbState.ON;
  32.  
  33. else if (state == bulbState.ON)
  34. state = bulbState.OFF;
  35.  
  36. }
  37.  
  38. count++;
  39. }
  40.  
  41.  
  42.  
  43. }
Add Comment
Please, Sign In to add comment