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

39 lines
847 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;
}
2024-04-16 13:18:28 +02:00
@Override
2024-04-16 12:56:14 +02:00
public Integer getValue() {
return value;
}
2024-04-16 13:02:44 +02:00
public Word add(Word other) {
return new IntWord(value + (Integer) other.getValue());
2024-04-16 12:42:57 +02:00
}
2024-04-16 13:02:44 +02:00
public Word subtract(Word other) {
return new IntWord(value - (Integer) other.getValue());
2024-04-16 12:42:57 +02:00
}
2024-04-16 13:02:44 +02:00
public Word multiply(Word value) {
return new IntWord(this.value * (Integer) value.getValue());
2024-04-16 12:42:57 +02:00
}
2024-04-16 13:02:44 +02:00
public Word divide(Word other) {
return new IntWord(value / (Integer) other.getValue());
2024-04-16 12:42:57 +02:00
}
2024-04-16 13:18:28 +02:00
public String toString() {
return value.toString();
}
2024-04-16 14:24:01 +02:00
public boolean equals(Object other) {
return value.equals(((IntWord) other).getValue());
}
2024-04-16 12:42:57 +02:00
}