| 1234567891011121314151617181920212223242526272829303132333435 |
- package eu.oschl.textadventure.objects;
- import java.util.Optional;
- /**
- * Represents an object in the game that can be picked up by the player.
- * This class serves as a base for all pickable objects, providing common properties and methods.
- *
- * @author Ondřej Schlaichert
- */
- public abstract class PickableObject extends GameObject {
- private final String iconImagePath;
- public PickableObject(String name, String description, String iconImagePath) {
- super(name, description);
- this.iconImagePath = iconImagePath;
- }
- public PickableObject(String name, String description) {
- super(name, description);
- this.iconImagePath = null;
- }
- public Optional<String> getIconImagePath() {
- return Optional.ofNullable(iconImagePath);
- }
- /**
- * Picks up the object and adds it to the player's inventory.
- * @return true if the object was successfully picked up, false otherwise
- */
- public abstract boolean pickUp();
- }
|