Code covered by the BSD License  

Highlights from
BattleShip (R)

image thumbnail

BattleShip (R)

by

 

23 Oct 2008 (Updated )

Learn and have fun with an old classic.

atgridpt(position,row,col)
function obj = atgridpt(position,row,col)
%  	Author: Isaac Noh
%   Copyright 2008-2009 The MathWorks, Inc.
%   Version: 1.1


if nargin == 0
    obj.handle = 0;
else
% "Constructor" for psuedo object ATGRIDPT
obj.handle = uicontrol('Style','radiobutton',...
    'Units','normalized',...
    'Position',position,...
    'BackgroundColor', [0 0 0.7],...
    'UserData',[row col]);
end

% Methods for ATGRIDPT
obj.sethit = @sethit;
obj.gethit = @gethit;
obj.settarget = @settarget;
obj.gettarget = @gettarget;
obj.setlocation = @setlocation;
obj.getlocation = @getlocation;

% Properties for ATGRIDPT
hit = false;
target = false;
location = '';

% Definition of methods
    function obj = sethit(val)
        % val should be of datatype logical
        hit = val;
    end

    function out = gethit
        % val should be of datatype logical
        out = hit;
    end

    function obj = settarget(val)
        % val should be of datatype logical
        target = val;
    end

    function out = gettarget
        % val should be of datatype logical
        out = target;
    end

    function obj = setlocation(val)
        % val should be of datatype char
        location = val;
    end

    function out = getlocation
        % val should be of datatype char
        out = location;
    end

end

Contact us