function [nextState, output] = update( currentState, input )
switch currentState
    case 'happy'
        nextState = 'happy';
        if strcmp (input, 'pet')
            output = 'purrs';
        elseif strcmp (input, 'feed')
            output = 'throws up';
        elseif strcmp (input, 'time passes') 
            output = 'rubs';
            nextState = 'hungry';
        else output = 'absent'; %I don't understand what u said
        end
    case 'hungry'
        if strcmp (input, 'pet')
            nextState = 'hungry';
            output = 'bites';
        elseif strcmp (input, 'feed')            
            nextState = 'happy';
            output = 'purrs';
        elseif strcmp (input, 'time passes') 
            output = 'dies';
            nextState = 'dead';
        else 
            output = 'absent';
            nextState = 'hungry';
        end        
    otherwise
        nextState = 'dead';
        output = 'absent';
end 
