mirror of
https://github.com/soconnor0919/eceg431.git
synced 2025-12-11 22:54:43 -05:00
project10 - template
This commit is contained in:
99
10/ExpressionLessSquare/Square.jack
Normal file
99
10/ExpressionLessSquare/Square.jack
Normal file
@@ -0,0 +1,99 @@
|
||||
// This file is part of www.nand2tetris.org
|
||||
// and the book "The Elements of Computing Systems"
|
||||
// by Nisan and Schocken, MIT Press.
|
||||
/// File name: projects/10/ExpressionLessSquare/Square.jack
|
||||
|
||||
/** Expressionless version of projects/10/Square/Square.jack. */
|
||||
|
||||
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 x;
|
||||
}
|
||||
|
||||
method void dispose() {
|
||||
do Memory.deAlloc(this);
|
||||
return;
|
||||
}
|
||||
|
||||
method void draw() {
|
||||
do Screen.setColor(x);
|
||||
do Screen.drawRectangle(x, y, x, y);
|
||||
return;
|
||||
}
|
||||
|
||||
method void erase() {
|
||||
do Screen.setColor(x);
|
||||
do Screen.drawRectangle(x, y, x, y);
|
||||
return;
|
||||
}
|
||||
|
||||
method void incSize() {
|
||||
if (x) {
|
||||
do erase();
|
||||
let size = size;
|
||||
do draw();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
method void decSize() {
|
||||
if (size) {
|
||||
do erase();
|
||||
let size = size;
|
||||
do draw();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
method void moveUp() {
|
||||
if (y) {
|
||||
do Screen.setColor(x);
|
||||
do Screen.drawRectangle(x, y, x, y);
|
||||
let y = y;
|
||||
do Screen.setColor(x);
|
||||
do Screen.drawRectangle(x, y, x, y);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
method void moveDown() {
|
||||
if (y) {
|
||||
do Screen.setColor(x);
|
||||
do Screen.drawRectangle(x, y, x, y);
|
||||
let y = y;
|
||||
do Screen.setColor(x);
|
||||
do Screen.drawRectangle(x, y, x, y);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
method void moveLeft() {
|
||||
if (x) {
|
||||
do Screen.setColor(x);
|
||||
do Screen.drawRectangle(x, y, x, y);
|
||||
let x = x;
|
||||
do Screen.setColor(x);
|
||||
do Screen.drawRectangle(x, y, x, y);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
method void moveRight() {
|
||||
if (x) {
|
||||
do Screen.setColor(x);
|
||||
do Screen.drawRectangle(x, y, x, y);
|
||||
let x = x;
|
||||
do Screen.setColor(x);
|
||||
do Screen.drawRectangle(x, y, x, y);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user