Create a program that demonstrates how to create class files and objects using object-oriented programming. Think...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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 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
Expert Answer:
Related Book For
Java How To Program Late Objects Version
ISBN: 9780136123712
8th Edition
Authors: Paul Deitel, Deitel & Associates
Posted Date:
Students also viewed these programming questions
-
In a Hopfield neural network configured as an associative memory, with all of its weights trained and fixed, what three possible behaviours may occur over time in configuration space as the net...
-
In this question you will be asked to reflect on a project you have been involved in or observed, in which a design evolved, or could have evolved, through applying a theory of user behaviour. You...
-
The passage indicates that the late 1850s Democrats: F. Were all Southern slaveholders who wanted to expand slavery into the territories. G. Used legislation in the early 1850s to support their...
-
1. When a generator is used to produce electric current, the resulting electric energy originates from which source? (a) The generator's magnetic field. (b)Whatever rotates the generator's axle. (c)...
-
Explain the going concern concept.
-
Take the product of the perturbation velocity equation given by Eq. (17.53) by any component of the perturbation velocity. This results in an equation for \(v_{x}^{\prime} v_{y}^{\prime}\), which is...
-
A review of emergency room records at rural Millard Fell more Memorial Hospital was performed to determine the probability distribution of the number of patients entering the emergency room during a...
-
Harrison Company makes two products and uses a traditional costing system in which a single plantwide predetermined overhead rate is computed based on direct labor-hours. Data for the two products...
-
Complete Form 941 for the 4th quarter for TCLH Industries (which is located at 202 Whitmore Avenue, Durham, NC 27701; Employer Identification #44-4444444). Assume that all necessary deposits were...
-
If a PeakVue spectrum for a 1200 RPM machine uses an Fmax of 40 orders, which filter should be used? A) 1,000 Hz high pass filter B) 5,000 Hz high pass filter C) 1,000 Hz low pass filter D) 5,000 Hz...
-
How can you decide the order of investment in a staged investment decision?
-
What is the average stock price reaction to an SEO?
-
List four types of corporate debt that are typically issued.
-
Why is it inappropriate to compare leasing to buying?
-
Why do companies provide trade credit?
-
Prepare Fund flow statement from the following Balance sheets- Liabilities Equity Share Capital Preference Share capital 6% Debentures General Reserve Profit & Loss A/c Creditors Provision for tax...
-
Dawson Companys balance sheet information at the end of 2019 and 2020 is as follows: Additional information: The company did not issue any common stock during 2020. Required : Next Level Fill in the...
-
Import class Scanner then create a Scanner object input for reading from System.in. What happens when you execute the statement: int number = input.nextInt() and the user enters the string "hello"?
-
Write a method recursiveBubbleSort that uses recursive techniques to perform an ascending bubble sort on an array of integers. The method should receive the array and an integer representing the...
-
Create a class called Complex for performing arithmetic with complex numbers. Complex numbers have the form realPart + imaginaryPart * i where i is Write a program to test your class. Use...
-
Sumitomo Cable manufactures various types of aluminum and copper cables which it sells directly to retail outlets through its distribution channels. The manufacturing process for producing cables...
-
The Cooper Furniture Company of Potomac, Maryland, assembles two types of chairs (Recliners and Rockers). Separate assembly lines are used for each type of chair. Classify each cost item (AI) as...
-
The following data are for Marvin Department Store. The account balances (in thousands) are for 2017. 1. Compute (a) the cost of goods purchased and (b) the cost of goods sold. 2. Prepare the income...
Study smarter with the SolutionInn App