uni

Thing1's amazing uni repo
Log | Files | Refs | Submodules

Treasure.java (1124B)


      1 package Monster;
      2 
      3 import java.io.PrintWriter;
      4 
      5 /**
      6  * stores the kind of Treasure
      7  */
      8 enum TreasureType {
      9 	GEM,
     10 	COIN,
     11 	POTION
     12 }
     13 
     14 public class Treasure {
     15 	private TreasureType treasureType;
     16 	private String treasureColor;
     17 	private int specialPowerPoints;
     18 
     19 	public Treasure(TreasureType treasureType, String treasureColor, int specialPowerPoints) {
     20 		this.treasureType = treasureType;
     21 		this.treasureColor = treasureColor;
     22 		this.specialPowerPoints = specialPowerPoints;
     23 	}
     24 
     25 	public TreasureType getTreasureType() {
     26 		return this.treasureType;
     27 	}
     28 
     29 	public void setTreasureColor(String treasureColor) {
     30 		this.treasureColor = treasureColor;	
     31 	}
     32 
     33 	public String getTreasureColor() {
     34 		return this.treasureColor;
     35 	}
     36 
     37 	public void setPowerPoints(int specialPowerPoints) {
     38 		this.specialPowerPoints = specialPowerPoints;
     39 	}
     40 
     41 	public int getPowerPoints() {
     42 		return this.specialPowerPoints;
     43 	}
     44 
     45 	public String toString() {
     46 		return "A " + this.treasureColor + " " + this.treasureType;
     47 	}
     48 
     49 	public void saveTreasure(PrintWriter pr) {
     50 		pr.printf("%s\n%s\n%d\n", this.treasureType, this.treasureColor, this.specialPowerPoints);
     51 	}
     52 };