Code covered by the BSD License  

Highlights from
Cribbage Suite

image thumbnail
from Cribbage Suite by Bryan
Cribbage Suite is a GUI interface designed to help teach and play the game of cribbage.

cribCard(varargin)
function r = cribCard(varargin)
%CONSTRUCTOR for class "cribCard", a child class of "cardDeck"
%Fieldnames are:
%   count: number of points (1-10, 10 for face cards)


w = what('cribCard');
a = [w.path];
saveLoc = [a filesep 'private' filesep 'nominal.mat'];

nominal = cribCardInit;
save(saveLoc,'nominal');
load(saveLoc);

if nargout == 0
    disp(nominal)
    return
end

if nargin == 0
    r = nominal;
elseif nargin >1
    r = cribCardInit;
    r = r(1);
    set(r,varargin)
end

end

%% Initialize blank
function y = cribCardInit
%Initializes a blank cribCard
s = cardDeck;
for i = 1:52
    temp = struct(s(i));
    temp = temp.face;
    if isequal(class(temp),'double')
        y(i).count = temp;
    else
        if isequal(temp,'a')
            y(i).count = 1;
        else
            y(i).count = 10;
        end
    end
end
y = class(y,'cribCard',cardDeck);
end

Contact us at files@mathworks.com