SHARE
TWEET

Untitled

a guest Apr 22nd, 2019 94 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class Item {
  2.  
  3.     private String name;
  4.     private int price;
  5.     private String description;
  6.    
  7.     public String getName() {
  8.         return name;
  9.     }
  10.    
  11.     public int getPrice() {
  12.         return price;
  13.     }
  14.    
  15.     public String getDescription() {
  16.         return description;
  17.     }
  18.    
  19.     public Item(String itemName, int itemPrice, String itemDescription) {
  20.         name = itemName;
  21.         price = itemPrice;
  22.         description = itemDescription;
  23.        
  24.     }
  25.    
  26.    
  27. }
  28.  
  29.  
  30.  
  31.  
  32.  
  33. public class FoodItem extends Item {
  34.  
  35.     public FoodItem(String itemName, int itemPrice, String itemDescription) {
  36.         super(itemName, itemPrice, itemDescription);
  37.     }
  38.    
  39.     public void useItem() {
  40.         System.out.println("You have used a food item!");
  41.     }
  42.    
  43.  
  44. }
  45.  
  46.  
  47.  
  48.  
  49.  
  50. public class Medicalitem extends Item {
  51.    
  52.     private boolean curesSpacePlauge;
  53.  
  54.     public Medicalitem(String itemName, int itemPrice, String itemDescription, boolean curesPlague) {
  55.         super(itemName, itemPrice, itemDescription);
  56.         curesSpacePlauge = curesPlague;
  57.     }
  58.    
  59.     public boolean doesCurePlauge() {
  60.         return curesSpacePlauge;
  61.     }
  62.    
  63.     public void useItem() {
  64.         System.out.println("You have used a medical item!");
  65.     }
  66.    
  67. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top