Checkpoint 3
This commit is contained in:
parent
e0845968a1
commit
f7e3b00408
4 changed files with 12 additions and 2 deletions
|
@ -10,4 +10,8 @@ public class Address {
|
||||||
public int getAddress() {
|
public int getAddress() {
|
||||||
return address;
|
return address;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return Integer.toString(address);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ public abstract class Instruction {
|
||||||
|
|
||||||
for (Object operand : this.operands()) {
|
for (Object operand : this.operands()) {
|
||||||
sb.append(" ");
|
sb.append(" ");
|
||||||
sb.append(operand);
|
sb.append(operand.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
|
|
|
@ -7,6 +7,7 @@ public class IntWord extends Word {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Integer getValue() {
|
public Integer getValue() {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
@ -26,4 +27,8 @@ public class IntWord extends Word {
|
||||||
public Word divide(Word other) {
|
public Word divide(Word other) {
|
||||||
return new IntWord(value / (Integer) other.getValue());
|
return new IntWord(value / (Integer) other.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return value.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
package hatelace;
|
package hatelace;
|
||||||
|
|
||||||
public abstract class Word {
|
public abstract class Word {
|
||||||
public abstract <T> T getValue();
|
public abstract Integer getValue();
|
||||||
public abstract Word add(Word other);
|
public abstract Word add(Word other);
|
||||||
public abstract Word subtract(Word other);
|
public abstract Word subtract(Word other);
|
||||||
public abstract Word multiply(Word other);
|
public abstract Word multiply(Word other);
|
||||||
public abstract Word divide(Word other);
|
public abstract Word divide(Word other);
|
||||||
|
public abstract String toString();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue