package eecs1022.midtermb; import android.graphics.Color; /** * This class represents the model of the app. A toggle can either be on or off. * Initially, a toggle is on. The it() method switched the toggle from on to off * or from off to on. * * @author Franck van Breugel */ public class Toggle { private boolean on; /** * Initializes this toggle by setting it to on. */ public Toggle() { this.on = true; } /** * Switched this toggle from on to off or from off to on. */ public void it() { this.on = !this.on; } /** * Returns the text "Press me" if this toggle is on, and * returns the text "Again" if this toggle is off. * * @return "Press me" or "Again". */ public String getText() { if (this.on) { return "Press me"; } else { return "Again"; } } /** * Returns the color Color.GREEN if this toggle is on, and * returns the color Color.RED if this toggle is off. * * @return the color green or red. */ public int getColor() { if (this.on) { return Color.GREEN; } else { return Color.RED; } } }