summaryrefslogtreecommitdiff
path: root/projects/12/OutputTest/Output.jack
diff options
context:
space:
mode:
authorYuchen Pei <me@ypei.me>2018-01-17 18:35:55 +0100
committerYuchen Pei <me@ypei.me>2018-01-17 18:35:55 +0100
commit01da7177bd2f4d83e8916540a69d8b2690b52bbb (patch)
treebe320d5a30c62cfb93eee1333244e53a75811121 /projects/12/OutputTest/Output.jack
parentc89bcc6a364ded67504e88db1bf71417250e2ea3 (diff)
finished project 12
- revised output - finished string
Diffstat (limited to 'projects/12/OutputTest/Output.jack')
-rw-r--r--projects/12/OutputTest/Output.jack28
1 files changed, 4 insertions, 24 deletions
diff --git a/projects/12/OutputTest/Output.jack b/projects/12/OutputTest/Output.jack
index 05d59de..61b24de 100644
--- a/projects/12/OutputTest/Output.jack
+++ b/projects/12/OutputTest/Output.jack
@@ -254,30 +254,10 @@ class Output {
/** Displays the given integer starting at the cursor location,
* and advances the cursor appropriately. */
function void printInt(int i) {
- var int n, k, j;
- var Array s;
- if (i = 0) {
- do Output.printChar(48);
- return;
- }
- let n = i;
- if (i < 0) {
- do Output.printChar(45);
- let n = -n;
- }
- let s = Array.new(5);
- let j = 0;
- while (n > 0) {
- let k = n / 10;
- let s[j] = 48 + n - (k * 10);
- let n = k;
- let j = j + 1;
- }
- while (j > 0) {
- let j = j - 1;
- do Output.printChar(s[j]);
- }
- //do Output.printString(s);
+ var String s;
+ let s = String.new(6);
+ do s.setInt(i);
+ do Output.printString(s);
return;
}