Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package it.cefi.models;
- public class Lampadina {
- private static Lampadina instance;
- private Lampadina() {
- }
- public static synchronized Lampadina getInstance() {
- if (instance == null) {
- instance = new Lampadina();
- }
- return instance;
- }
- public bulbState state = bulbState.OFF;
- public int count = 0;
- public void click() {
- if (count > 9) {
- state = bulbState.BROKEN;
- count = 9;
- } else {
- if (state == bulbState.OFF)
- state = bulbState.ON;
- else if (state == bulbState.ON)
- state = bulbState.OFF;
- }
- count++;
- }
- }
Add Comment
Please, Sign In to add comment