Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Dragon
- {
- private String attack;
- private int level;
- // Write the constructor here!
- public Dragon (int theLevel, String theAttack)
- {
- attack = theAttack;
- level = theLevel;
- }
- // Put getters here
- public String getAttack()
- {
- return attack;
- }
- public int getLevel()
- {
- return level;
- }
- // Put other methods here
- public String fight()
- {
- String retStr = "";
- for(int i = 0; i < level; i++)
- {
- retStr += attack;
- }
- return retStr;
- }
- // String representation of the object
- public String toString()
- {
- return "Dragon is at level " + level + " and attacks with " + attack;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement