HateLace/app/src/main/java/hatelace/IntWord.java

30 lines
671 B
Java
Raw Normal View History

2024-04-16 12:42:57 +02:00
package hatelace;
public class IntWord extends Word {
private Integer value;
public IntWord(Integer value) {
this.value = value;
}
public <T> T getValue() {
return (T) value;
}
public <T> T add(Word other) {
return (T) new IntWord(value + (Integer) other.getValue());
}
public <T> T subtract(Word other) {
return (T) new IntWord(value - (Integer) other.getValue());
}
public <T> T multiply(Word other) {
return (T) new IntWord(value * (Integer) other.getValue());
}
public <T> T divide(Word other) {
return (T) new IntWord(value / (Integer) other.getValue());
}
}