Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Item {
- private String name;
- private int price;
- private String description;
- public String getName() {
- return name;
- }
- public int getPrice() {
- return price;
- }
- public String getDescription() {
- return description;
- }
- public Item(String itemName, int itemPrice, String itemDescription) {
- name = itemName;
- price = itemPrice;
- description = itemDescription;
- }
- }
- public class FoodItem extends Item {
- public FoodItem(String itemName, int itemPrice, String itemDescription) {
- super(itemName, itemPrice, itemDescription);
- }
- public void useItem() {
- System.out.println("You have used a food item!");
- }
- }
- public class Medicalitem extends Item {
- private boolean curesSpacePlauge;
- public Medicalitem(String itemName, int itemPrice, String itemDescription, boolean curesPlague) {
- super(itemName, itemPrice, itemDescription);
- curesSpacePlauge = curesPlague;
- }
- public boolean doesCurePlauge() {
- return curesSpacePlauge;
- }
- public void useItem() {
- System.out.println("You have used a medical item!");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement