HateLace/app/src/main/java/hatelace/IntWord.java
2024-04-16 13:18:28 +02:00

34 lines
739 B
Java

package hatelace;
public class IntWord extends Word {
private Integer value;
public IntWord(Integer value) {
this.value = value;
}
@Override
public Integer getValue() {
return value;
}
public Word add(Word other) {
return new IntWord(value + (Integer) other.getValue());
}
public Word subtract(Word other) {
return new IntWord(value - (Integer) other.getValue());
}
public Word multiply(Word value) {
return new IntWord(this.value * (Integer) value.getValue());
}
public Word divide(Word other) {
return new IntWord(value / (Integer) other.getValue());
}
public String toString() {
return value.toString();
}
}