class
Square
{
field
int
x
,
y
;
field
int
size
;
constructor
Square
new
(
int
Ax
,
int
Ay
,
int
Asize
)
{
let
x
=
Ax
;
let
y
=
Ay
;
let
size
=
Asize
;
do
draw
(
)
;
return
this
;
}
method
void
dispose
(
)
{
do
Memory
.
deAlloc
(
this
)
;
return
;
}
method
void
draw
(
)
{
do
Screen
.
setColor
(
true
)
;
do
Screen
.
drawRectangle
(
x
,
y
,
x
+
size
,
y
+
size
)
;
return
;
}
method
void
erase
(
)
{
do
Screen
.
setColor
(
false
)
;
do
Screen
.
drawRectangle
(
x
,
y
,
x
+
size
,
y
+
size
)
;
return
;
}
method
void
incSize
(
)
{
if
(
(
(
y
+
size
)
<
254
)
&
(
(
x
+
size
)
<
510
)
)
{
do
erase
(
)
;
let
size
=
size
+
2
;
do
draw
(
)
;
}
return
;
}
method
void
decSize
(
)
{
if
(
size
>
2
)
{
do
erase
(
)
;
let
size
=
size
-
2
;
do
draw
(
)
;
}
return
;
}
method
void
moveUp
(
)
{
if
(
y
>
1
)
{
do
Screen
.
setColor
(
false
)
;
do
Screen
.
drawRectangle
(
x
,
(
y
+
size
)
-
1
,
x
+
size
,
y
+
size
)
;
let
y
=
y
-
2
;
do
Screen
.
setColor
(
true
)
;
do
Screen
.
drawRectangle
(
x
,
y
,
x
+
size
,
y
+
1
)
;
}
return
;
}
method
void
moveDown
(
)
{
if
(
(
y
+
size
)
<
254
)
{
do
Screen
.
setColor
(
false
)
;
do
Screen
.
drawRectangle
(
x
,
y
,
x
+
size
,
y
+
1
)
;
let
y
=
y
+
2
;
do
Screen
.
setColor
(
true
)
;
do
Screen
.
drawRectangle
(
x
,
(
y
+
size
)
-
1
,
x
+
size
,
y
+
size
)
;
}
return
;
}
method
void
moveLeft
(
)
{
if
(
x
>
1
)
{
do
Screen
.
setColor
(
false
)
;
do
Screen
.
drawRectangle
(
(
x
+
size
)
-
1
,
y
,
x
+
size
,
y
+
size
)
;
let
x
=
x
-
2
;
do
Screen
.
setColor
(
true
)
;
do
Screen
.
drawRectangle
(
x
,
y
,
x
+
1
,
y
+
size
)
;
}
return
;
}
method
void
moveRight
(
)
{
if
(
(
x
+
size
)
<
510
)
{
do
Screen
.
setColor
(
false
)
;
do
Screen
.
drawRectangle
(
x
,
y
,
x
+
1
,
y
+
size
)
;
let
x
=
x
+
2
;
do
Screen
.
setColor
(
true
)
;
do
Screen
.
drawRectangle
(
(
x
+
size
)
-
1
,
y
,
x
+
size
,
y
+
size
)
;
}
return
;
}
}