package FSMmacchinaCaffe;

import nz.ac.waikato.modeljunit.Action;
import nz.ac.waikato.modeljunit.FsmModel;

public class maccCaffe implements FsmModel {

	enum State {
		coin0, coin1, coin2, coin3, coin4, coin5
	};

	State state;

	public maccCaffe() {
		state = State.coin0;
	}

	@Action
	public void insertCoin() {
		if (this.state.equals(State.coin5))
			System.out.println("macchina piena");
		if (this.state.equals(State.coin4))
			this.state = State.coin5;
		if (this.state.equals(State.coin3))
			this.state = State.coin4;
		if (this.state.equals(State.coin2))
			this.state = State.coin3;
		if (this.state.equals(State.coin1))
			this.state = State.coin2;
		if (this.state.equals(State.coin0))
			this.state = State.coin1;
	}

	@Action
	public void getNormalCoffee() {
		if (this.state.equals(State.coin5))
			this.state = State.coin4;
		else if (this.state.equals(State.coin4))
			this.state = State.coin3;
		else if (this.state.equals(State.coin3))
			this.state = State.coin2;
		else if (this.state.equals(State.coin2))
			this.state = State.coin1;
		else if (this.state.equals(State.coin1))
			this.state = State.coin0;
		else if (this.state.equals(State.coin0))
			System.out.println("coin insufficienti");
	}

	@Action
	public void getSuperCoffee() {
		if (this.state.equals(State.coin5))
			this.state = State.coin3;
		else if (this.state.equals(State.coin4))
			this.state = State.coin2;
		else if (this.state.equals(State.coin3))
			this.state = State.coin1;
		else if (this.state.equals(State.coin2))
			this.state = State.coin0;
		else if (this.state.equals(State.coin1))
			System.out.println("coin insufficienti");
		else if (this.state.equals(State.coin0))
			System.out.println("coin insufficienti");
	}

	@Override
	public Object getState() {
		return state;
	}

	@Override
	public void reset(boolean arg0) {
		state = State.coin0;
	}
}
