[U2Q] Verification, as a step in the firming process, includ…
Verification, as a step in the firming process, includes:
[U2Q] Verification, as a step in the firming process, includ…
Questions
[U2Q] Verificаtiоn, аs а step in the firming prоcess, includes:
Open the fоllоwing website: https://www.prоgrаmiz.com/jаvа-programming/online-compiler/ Encapsulation (10 points) Create a class named Warrior that contains a field for the wound points the Warrior can cause. Provide a 1 argument constructor and get/set methods for the field. Make sure that a negative number of points cannot get set in the constructor or the setter method. Create a toString() method that returns a string like the example output below. Inheritance (10 points) Create a subclass of Warrior named HorseWarrior that contains a field for the sound the HorseWarrior makes. Provide get/set methods for the field and a 2 argument constructor. Create a toString() method that uses Warrior ’s toString(). Polymorphism (10 points) Create a main program that creates an array of 3 Warriors. Make the first two elements Warrior objects and make the third element a HorseWarrior object. No user input is required. Add a loop that runs through your array, printing each object. (Note: output so far would be something like this...) This warrior does 3 wound points. This warrior does 5 wound points. This warrior does 10 wound points. It goes HISS! Exceptions (10 points) Create an empty exception class named NoWound for the Warrior class. Add a default constructor to your Warrior class that simply throws a NoWound exception. Attempt to create a Warrior object with no wound points (underneath the code that is already working from problems 1-4). Display the result. Complete Example output (with all pieces completed): This warrior does 3 wound points. This warrior does 5 wound points. This warrior does 10 wound points. It goes HISS! Error: The warrior must be assigned wound points. In this question paste your Java code
Open the fоllоwing website: https://www.prоgrаmiz.com/jаvа-programming/online-compiler/ Encapsulation (10 points) Create a class named Warrior that contains a field for the wound points the Warrior can cause. Provide a 1 argument constructor and get/set methods for the field. Make sure that a negative number of points cannot get set in the constructor or the setter method. Create a toString() method that returns a string like the example output below. Inheritance (10 points) Create a subclass of Warrior named HorseWarrior that contains a field for the sound the HorseWarrior makes. Provide get/set methods for the field and a 2 argument constructor. Create a toString() method that uses Warrior ’s toString(). Polymorphism (10 points) Create a main program that creates an array of 3 Warriors. Make the first two elements Warrior objects and make the third element a HorseWarrior object. No user input is required. Add a loop that runs through your array, printing each object. (Note: output so far would be something like this...) This warrior does 3 wound points. This warrior does 5 wound points. This warrior does 10 wound points. It goes HISS! Exceptions (10 points) Create an empty exception class named NoWound for the Warrior class. Add a default constructor to your Warrior class that simply throws a NoWound exception. Attempt to create a Warrior object with no wound points (underneath the code that is already working from problems 1-4). Display the result. Complete Example output (with all pieces completed): This warrior does 3 wound points. This warrior does 5 wound points. This warrior does 10 wound points. It goes HISS! Error: The warrior must be assigned wound points. In this question copy and paste your code