home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1998 October
/
PCWorld_1998-10_cd.bin
/
software
/
prehled
/
komix
/
DATA.Z
/
TicTacToe_Cell.sru
< prev
next >
Wrap
Text File
|
1997-09-30
|
3KB
|
105 lines
$PBExportHeader$tictactoe_cell.sru
$PBExportComments$Generated by ObjectTeam
forward
global type tictactoe_cell from nonvisualobject
end type
end forward
shared variables
// User defined attributes
// Non modeled user defined attributes
end variables
global type tictactoe_cell from nonvisualobject
end type
global tictactoe_cell tictactoe_cell
type variables
// User defined attributes
string contents = ' '
// Association attributes
private classdict neighbourDict
// Non modeled user defined attributes
// Control to class mappings
// tictactoe_cell --> TicTacToe_Cell
end variables
forward prototypes
public function integer getMaxLine ()
public function integer getLine (string dir, string x)
public function tictactoe_cell getNeighbour (string Direction)
public subroutine setNeighbour (string Direction, tictactoe_cell newNeighbour)
public subroutine removeNeighbour (string Direction)
end prototypes
public function integer getMaxLine ();//
integer maxValue
integer lineValue
maxValue = getLine('N', contents) + getLine('S', contents) - 1
lineValue = getLine('E', contents) + getLine('W', contents) - 1
IF (maxValue < lineValue) THEN maxValue = lineValue
lineValue = getLine('NE', contents) + getLine('SW', contents) - 1
IF (maxValue < lineValue) THEN maxValue = lineValue
lineValue = getLine('NW', contents) + getLine('SE', contents) - 1
IF (maxValue < lineValue) THEN maxValue = lineValue
return maxValue
end function
public function integer getLine (string dir, string x);//
tictactoe_cell cell
integer retValue = 0
IF (contents = x) THEN
retValue = 1
cell = getNeighbour(dir)
IF NOT isNull(cell) THEN
retValue = retValue + cell.getLine(dir, x)
END IF
END IF
return retValue
end function
public function tictactoe_cell getNeighbour (string Direction);// Association accessor method
return neighbourDict.get(Direction)
end function
public subroutine setNeighbour (string Direction, tictactoe_cell newNeighbour);// Association accessor method
if isNull(newNeighbour) then
return
end if
neighbourDict.set(Direction, newNeighbour)
end subroutine
public subroutine removeNeighbour (string Direction);// Association accessor method
powerobject object
object = neighbourDict.get(Direction)
if isNull(object) then
return
end if
neighbourDict.remove(Direction)
end subroutine
on tictactoe_cell.create
TriggerEvent( this, "constructor" )
end on
on tictactoe_cell.destroy
TriggerEvent( this, "destructor" )
end on
event constructor;neighbourDict = create classdict
// Start user code section
// End user code section
end event
event destructor;// Start user code section
// End user code section
destroy(neighbourDict)
setNull(neighbourDict)
end event