Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.15 KB | None | 0 0
  1.  
  2. /**
  3.  * Player item-klasse
  4.  *
  5.  * @author Terje Nesthus (tne037)
  6.  * @version 1.0
  7.  */
  8. public class Item
  9. {
  10.     private String name;
  11.     private String description;
  12.     private String action;
  13.     private int value;
  14.  
  15.     /**
  16.      * Konstruktør for objekter av klassen Item
  17.      *
  18.      * @param Item name
  19.      * @param Item description
  20.      * @param Item action
  21.      * @param Item value
  22.      */
  23.     public Item(String name, String description, String action, int value)
  24.     {
  25.         this.setName(name);
  26.         this.setDescription(description);
  27.         this.setValue(value);
  28.         this.setAction(action);
  29.     }
  30.    
  31.     /**
  32.      * Sett item name
  33.      */
  34.     public void setName(String name)
  35.     {
  36.         this.name = Player.checkString(name);
  37.     }
  38.    
  39.     /**
  40.      * Hent ut item name
  41.      *
  42.      * @return Item name
  43.      */
  44.     public String getName()
  45.     {
  46.         return this.name;
  47.     }
  48.    
  49.     /**
  50.      * Sett item description
  51.      */
  52.     public void setDescription(String description)
  53.     {
  54.         this.description = Player.checkString(description);
  55.     }
  56.  
  57.     /**
  58.      * Hent ut item description
  59.      *
  60.      * @return Item description
  61.      */
  62.     public String getDescription()
  63.     {
  64.         return this.description;
  65.     }
  66.    
  67.     /**
  68.      * Sett item value
  69.      */
  70.     public void setValue(int value)
  71.     {
  72.         this.value = value;
  73.     }
  74.  
  75.     /**
  76.      * Hent ut item value
  77.      *
  78.      * @return Item value
  79.      */
  80.     public int getValue()
  81.     {
  82.         return this.value;
  83.     }
  84.    
  85.     /**
  86.      * Sett item action
  87.      */
  88.     public void setAction(String action)
  89.     {
  90.         this.action = Player.checkString(action);
  91.     }
  92.  
  93.     /**
  94.      * Hent ut item action
  95.      *
  96.      * @return Item action
  97.      */
  98.     public String getAction()
  99.     {
  100.         return this.action;
  101.     }
  102.  
  103.     /**
  104.      * Method print
  105.      *
  106.      * Prints the Item's name, description and value
  107.      */
  108.     public void print()
  109.     {
  110.         System.out.print(this.getName() + " - ");
  111.         System.out.print(this.getDescription() + " (");
  112.         System.out.println(this.getValue() + ")");
  113.     }
  114. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement