classdef systemClass < handle
    
    properties
        numStates
        numActions
        feasibleActions
        transArray
        payoffArray
        currentState
    end
    
    methods
        % Constructor
        function obj = systemClass(transArray, payoffArray, ...
                        feasibleActions, initialState)
            obj.transArray = transArray;
            obj.payoffArray = payoffArray;
            obj.feasibleActions = feasibleActions;
            obj.currentState = initialState;
            [obj.numStates, obj.numActions] = size(payoffArray);
        end

        function obj = setState(obj, state)
            obj.currentState = state;
        end
        
        function [contribution, nextState] = getNext(obj,action)
            contribution = obj.payoffArray(obj.currentState, action);
            nextState = find(1 == mnrnd(1,obj.transArray(obj.currentState,:,action)));
            obj.currentState = nextState;
        end
        
    end % methods 

end

