package org.nusco.narjillos.views.utilities;

public class PetriDishState {
	private volatile Light light = Light.ON;
	private volatile Speed speed = Speed.REALTIME;

	public Light getLight() {
		return light;
	}

	public Speed getSpeed() {
		return speed;
	}

	public void toggleLight() {
		if (light == Light.INFRARED)
			this.light = Light.ON;
		else if (light == Light.ON) {
			this.light = Light.OFF;
			this.speed = Speed.HIGH;
		}
		else {
			this.light = Light.ON;
			this.speed = Speed.REALTIME;
		}
	}

	public void toggleInfrared() {
		if (light == Light.OFF) {
			this.light = Light.INFRARED;
			this.speed = Speed.REALTIME;
		}
		else if (light == Light.INFRARED)
			this.light = Light.ON;
		else
			this.light = Light.INFRARED;
	}

	public void toggleSpeed() {
		if (speed == Speed.REALTIME)
			this.speed = Speed.HIGH;
		else
			this.speed = Speed.REALTIME;
	}
}

@@ -289,35 +289,40 @@
 %7B%0A%09%09
-if
+switch
  (light
- == Light.
+) %7B%0A%09%09case 
 INFRARED
 )%0A%09%09
@@ -309,33 +309,33 @@
 %0A%09%09case INFRARED
-)
+:
 %0A%09%09%09this.light =
@@ -351,37 +351,26 @@
 ;%0A%09%09
-else if (light == Light.ON) %7B
+%09break;%0A%09%09case ON:
 %0A%09%09%09
@@ -427,18 +427,27 @@
 ;%0A%09%09
-%7D%0A%09%09else %7B
+%09break;%0A%09%09case OFF:
 %0A%09%09%09
@@ -497,24 +497,34 @@
 d.REALTIME;%0A
+%09%09%09break;%0A
 %09%09%7D%0A%09%7D%0A%0A%09pub
@@ -557,121 +557,104 @@
 %7B%0A%09%09
-if
+switch
  (light
- == Light.OFF) %7B%0A%09%09%09this.light = Light.INFRARED;%0A%09%09%09this.speed = Speed.REALTIME;%0A%09%09%7D%0A%09%09else if (
+) %7B%0A%09%09case INFRARED:%0A%09%09%09this.light = Light.ON;%0A%09%09%09break;%0A%09%09case ON:%0A%09%09%09this.
 light =
-=
  Lig
@@ -668,74 +668,109 @@
 ARED
-)%0A%09%09%09this.light = Light.ON;%0A%09%09else%0A%09%09%09this.light = Light.INFRARED;
+;%0A%09%09%09break;%0A%09%09case OFF:%0A%09%09%09this.light = Light.INFRARED;%0A%09%09%09this.speed = Speed.REALTIME;%0A%09%09%09break;%0A%09%09%7D
 %0A%09%7D%0A
@@ -805,35 +805,40 @@
 %7B%0A%09%09
-if
+switch
  (speed
- == Speed.
+) %7B%0A%09%09case 
 REALTIME
 )%0A%09%09
@@ -833,17 +833,17 @@
 REALTIME
-)
+:
 %0A%09%09%09this
@@ -869,12 +869,28 @@
 ;%0A%09%09
-else
+%09break;%0A%09%09case HIGH:
 %0A%09%09%09
@@ -918,13 +918,27 @@
 ALTIME;%0A
+%09%09%09break;%0A%09%09%7D%0A
 %09%7D%0A%7D%0A

Refactor Petri Dish state machine