30 lines
671 B
Java
30 lines
671 B
Java
![]() |
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());
|
||
|
}
|
||
|
}
|