Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Create a program that demonstrates how to create class files and objects using object-oriented programming. Think of this as a first step in creating
Create a program that demonstrates how to create class files and objects using object-oriented programming. Think of this as a first step in creating a game and consider the user's interaction with the outputs. Brief Create two classes called Knight and Wizard. Each class has four data fields: O name health . O strength o agility Create accessor and mutator methods for each data field. When creating an object for each class the following must occur through the constructor: Name should be included as a parameter for all new objects. Wizard o o O . Knight Health is assigned a random number between 5 and 10. Agility is assigned a random number between 10 and 15. Strength is assigned a random number between 7 and 12. Health is assigned a random number between 20 and 40. Agility is assigned a random number between 5 and 10. Strength is assigned a random number between 13 and 35. Wizard methods: Attack method outputs a statement indicating the damage done is strength multiplied by a random number between 1 and 6. Special skill method outputs that a spell attack has done between 10 to 20 damage. Knight methods: Attack method outputs a statement indicating the damage done is strength multiplied by a random number between 1 and 6. O Special skill method outputs that a fury attack has done between 10 and 20 damage. Dodging method for each will be: int dodgeChance = int dodgeNumber if (dodgeChance > dodgeNumber) { } else { } = this.getAgility()*(int) (Math.random()*6); (int) (Math.random () *21); System.out.println(The attack missed."); System.out.println (The attack hit."); System.out.print(object) must output the values of the data fields in a user-friendly format. The class files will be tested against the Main file that is given. Computer Science 20 Rubric Variable names/1 Comments/1 Formatted /1 Variables /4 Accessor and Mutator Methods /4 Constructors/2 Action-based Methods /3 Runs without error /8
Step by Step Solution
There are 3 Steps involved in it
Step: 1
import javautilRandom public class Wizard private int strength private int agility public Wiza...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