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:
Answer rating: 100% (QA)
import javautilRandom public class Wizard private int strength private int agility public Wiza... View the full 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
-
Part A Set Task Information The redesign is for a flour tank system. The flour tank system consists of a plug, tank and tank platform with four legs. The tank, tank platform, tank platform legs and...
-
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. Which of the following statements about transformers is false? (a) Transformers work using ac current or dc current. (b) If the current in the secondary is higher, the voltage is lower. (c) If the...
-
Assume that by paying a $5 toll to use a hot lane, you could save six minutes on your commute to work, time that could be used productively in your office. What would your hourly wage rate (or...
-
The directors of Emerald plc (Emerald), an Irish listed company, have decided to adopt International Financial Reporting Standards (IFRS) for the first time in the company's financial statements for...
-
The 2012 comparative balance sheet and income statement of All Wired, Inc., follow: Additionally, All Wired purchased land of $24,500 by financing it 100% with longterm notes payable during 2012....
-
MY NOTES ASK YOUR TEACHER The following technology matrix describes the relationship of certain industries within the economy to each other. (A&F, agriculture and food; RM, raw materials; M,...
-
Your company is considering acquiring a private company (New Co., Inc.). The CFO has asked you to review the financial statements, look for key trends, and develop financial/operational questions to...
-
please asap The financial statements for Armstrong and Blair companies for the current year are summarized belowThe companies are in the same line of business and are direct competitors in a large...
-
On January 1, 2023, Hadley provided Ms. Kim with a $400,000 loan to assist with the purchase of a new home. The interest rate on the loan was 0.75% and monthly interest was withheld from each...
-
The inverse aggregate demand for energy is given by pt = 15 - wt, where wt = zt+Yt, zt is supply of the backstop, and Yt is supply of a non-renewable resource. z and y are perfect substitutes....
-
On December 31, 2026, Pink issued 50,000 shares of its common stock with a fair value of $35 per share for the net assets of Black. The following facts applied: Black dissolves immediately after the...
-
Gunlock Chair Co. is an elite manufacturer of mid-century modern solid oak chairs. At the start of May, the following budgeted unit amounts related to its manufacture of these exclusive oak chairs:...
-
Simplify the expression by combining like terms: 2x + 15x+13+10x+9x+6.
-
Culver Corp. makes and sells deck coating which is sold by the gallon. Two pounds of sand are needed to make one gallon of deck coating. Budgeted production of deck coating for the next two months...
-
Economic feasibility is an important guideline in designing cost accounting systems. Do you agree? Explain.
-
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...
-
The U.S. system leans toward a heavy education requirement mixed with practice, and the British system leans more toward a heavy experience requirement bordering on apprenticeship. Which system is...
-
If you were a certified accountant in your home country and wanted to practice as an auditor in another country, you would most likely not be allowed to practice. Why do these barriers to entry...
-
In this chapter, we discussed the personal qualifications, educational requirements, and experience requirements of different countries. Develop a matrix that includes countries down one side and the...
Study smarter with the SolutionInn App