@Override
	public void updateState() {
		int currentTime = Controller.getInstance().getTime();
		int cost = 0;
		
		/* This washing machine will only start washing between 2 pm and 5 pm
		 * and will take 2 hours to finish.
		 */
		if (this.state == State.ON)
			this.remainingTime -= Controller.getInstance().getIntervalDuration();
		hasFinished = (remainingTime <= 0);
		
		if (hasFinished || currentTime < startInterval)
			// If done washing, or not time to wash yet, don't pay anything.
			cost = 0;
		else if (!hasStarted && currentTime < endInterval)
			// If not started, but time to start watching, set price depending on how late it is
			cost = preferredCost + (CostFunction.MAX_COST - preferredCost) * (currentTime - startInterval) / (endInterval - startInterval);
		else
			// If already started, or we really need to start washing, set to our maximum price
			cost = CostFunction.MAX_COST;
		
		super.getCostFunction().updateCostForDemand(cost, demand);
	}