Checkpoint 3

This commit is contained in:
Imbus 2024-04-16 13:18:28 +02:00
parent e0845968a1
commit f7e3b00408
4 changed files with 12 additions and 2 deletions

View file

@ -10,4 +10,8 @@ public class Address {
public int getAddress() {
return address;
}
public String toString() {
return Integer.toString(address);
}
}

View file

@ -15,7 +15,7 @@ public abstract class Instruction {
for (Object operand : this.operands()) {
sb.append(" ");
sb.append(operand);
sb.append(operand.toString());
}
return sb.toString();

View file

@ -7,6 +7,7 @@ public class IntWord extends Word {
this.value = value;
}
@Override
public Integer getValue() {
return value;
}
@ -26,4 +27,8 @@ public class IntWord extends Word {
public Word divide(Word other) {
return new IntWord(value / (Integer) other.getValue());
}
public String toString() {
return value.toString();
}
}

View file

@ -1,9 +1,10 @@
package hatelace;
public abstract class Word {
public abstract <T> T getValue();
public abstract Integer getValue();
public abstract Word add(Word other);
public abstract Word subtract(Word other);
public abstract Word multiply(Word other);
public abstract Word divide(Word other);
public abstract String toString();
}