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;
|
|
|
|
}
|
|
|
|
|
2024-04-16 12:56:14 +02:00
|
|
|
// public <T> T getValue() {
|
|
|
|
// return value;
|
|
|
|
// }
|
|
|
|
|
|
|
|
public Integer getValue() {
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
public IntWord multiply(Word value) {
|
|
|
|
return new IntWord(this.value * (Integer) value.getValue());
|
2024-04-16 12:42:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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());
|
|
|
|
}
|
|
|
|
|
2024-04-16 12:56:14 +02:00
|
|
|
// public <T> T multiply(Word other) {
|
|
|
|
// return (T) new IntWord(value * (Integer) other.getValue());
|
|
|
|
// }
|
2024-04-16 12:42:57 +02:00
|
|
|
|
|
|
|
public <T> T divide(Word other) {
|
|
|
|
return (T) new IntWord(value / (Integer) other.getValue());
|
|
|
|
}
|
|
|
|
}
|