Answered step by step
Verified Expert Solution
Question
1 Approved Answer
New + Submit + Continue Save Output Test Cases Docs Assignment Grade More 2-{ 6 points Status: Not Submitted DragonTester.java Dragonjava 5.4.7 A Different Dragon
New + Submit + Continue Save Output Test Cases Docs Assignment Grade More 2-{ 6 points Status: Not Submitted DragonTester.java Dragonjava 5.4.7 A Different Dragon Class 1 public class DragonTester 3 public static void main(String[] args) { { 5 // Start here! 6 } 7 ] 4- Write a class called Dragon. A Dragon should have a name, a level. and a boolean variable, canBreatheFire, indicating whether or not the dragon can breathe fire. The class should have getter methods for all of these variables - getName, getLevel, and isFirebreather, respectively, Dragon will also need a constructor, a method to gain experience, and a a method to attack. The constructor should take the name as the first argument and the level as the second argument. The constructor should Initialize canBreatheFire based on the dragon's level. If the dragon is level 70 or higher, the dragon can breathe fire (meaning the third member variable should be set to true You should create three getter (accessor) methods called getName(). getLevel().and isFireBreathero. You should also create a method called attack. This method does not return anything. If the dragon can breathe fire, it should print >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>> That's 10 angle brackets, then 14, then 14, then 10 for copy and paste them!) if the dragon cannot breathe fire, it should print New + Save Output Test Cases Docs Assignment Grade More not return anything. If the dragon can breathe fire. It should print DragonTester.java Dragon.java >>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>> 0 5.4.7 A Different Dragon Class Submit + Continue 1 public class Dragon 2.[ 3 private String name; 4 private int level; 5 private boolean canBreatheFire; 6 7 // Write the constructor here! 8 9 // Put getters here 10 11 // Put other methods here 12 13 14 // String representation of the object 15 public String toStringo 16 { 17 return "Dragon " + name + " is at level " + level; " 18 } 19] That's 10 angle brackets, then 14, then 14, then 10 for copy and paste them!) If the dragon cannot breathe fire, it should print Finally, you should have a method called gain experience that takes no parameters. It should add 10 to the dragon's level and update canBreatheFire if necessary. In summary, you should have the following methods: A constructor that takes two parameters - the narre and level (in A that order) getName getLevel IsFireBreather gainExperlence attack
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started