Question: New + Save Output Test Ceses Docs Assignment Grade More 6 points Status: Not Submitted DragonTester.java Dragon.java 5.4.6 Full Dragon Class Submit + Continue 1


New + Save Output Test Ceses Docs Assignment Grade More 6 points Status: Not Submitted DragonTester.java Dragon.java 5.4.6 Full Dragon Class Submit + Continue 1 public class DragonTester 2. { public static void main(String[] args) { // Create a Dragon here to test out the Dragon class! } 7 } 3 4 5 6 Write a class called Dragon. A Dragon should have a level and an attack The class should have getter methods for each of these variables. The Dragon's level is an integer. The Dragon's attack is a String 8 Dragon will also need a constructor, getters, and an attack method. The constructor should take the level as the first argument and the attack as the second argument. You should create two getter (accessor) methods called getAttack and get Level You should also create a method called fight. This method should retum a string that repeats the attack string once for each level. For example, if the attack string is and the level is 6, then fight would return >>>>>> In summary, you should have the following methods: A constructor that takes two parameters - the level and attack (in that order) getAttack .getLevel fight New + Output Test Cases Docs Assignment Grade More DragonTester.java Dragon.java 6 points Status: Not Submitted Write a class called Dragon A Dragon should have a level and an attack. The class should have getter rrethods for each of these variables. The Dragon's level is an integer. The Dragon's attack is a String. Dragon will also need a constructor, getters, and an attack method. 5.4.6 Full Dragon Class Submit + Continue Save 1 public class Dragon 2. { 3 private String attack; 4 private int level; 5 6 // Write the constructor here! 7 8 8 // Put getters here 9 10 // Put other methods here 11 12 13 // String representation of the object 14 public String toString() 15 16 return "Dragon is at level " + level + " and attacks with " 17 } 18 ] 19 The constructor should take the level as the first argument and the attack as the second argument You should create two getter (accessor) methods called getAttack and get Level You should also create a method celled fight. This method should return a string that repeats the attack string once for each level. For example, if the attack string is ">" and the level is 6, then fight would return >>>>>> In summary, you should have the following methods: A constructor that takes two parameters - the level and attack in that order) getAttack .getLevel fight
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
