SHARE
TWEET

Untitled

a guest Feb 20th, 2019 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class Dragon
  2. {
  3.     private String name;
  4.     private int level;
  5.     private boolean canBreatheFire;
  6.    
  7.     // Write the constructor here!
  8.     public Dragon (String theName, int theLevel)
  9.     {
  10.         level = theLevel;
  11.         name = theName;
  12.     }
  13.     // Put getters here
  14.     public int gainExperience()
  15.     {
  16.         level += 10;
  17.         return level;
  18.     }
  19.     public int getLevel()
  20.     {
  21.         return level;
  22.     }
  23.     public String getName()
  24.     {
  25.         return name;
  26.     }
  27.     public String attack()
  28.     {
  29.         if(canBreatheFire == true)
  30.         {
  31.             System.out.println(">>>>>>>>>>");
  32.             System.out.println(">>>>>>>>>>>>>>");
  33.             System.out.println(">>>>>>>>>>>>>>");
  34.             System.out.println(">>>>>>>>>>");
  35.         }
  36.         else
  37.         {
  38.             System.out.println("~ ~ ~");
  39.         }
  40.         return "";
  41.     }
  42.     public boolean isFireBreather()
  43.     {
  44.         if(level >= 70)
  45.         {
  46.             canBreatheFire = true;
  47.             return true;
  48.         }
  49.         else
  50.         {
  51.             canBreatheFire = false;
  52.             return false;
  53.         }
  54.     }
  55.     // Put other methods here
  56.    
  57.  
  58.     // String representation of the object
  59.     public String toString()
  60.     {
  61.         return "Dragon " + name + " is at level " + level;
  62.     }
  63. }
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
 
Top