Scenario You need to create a software class that represents a warrior in a game program....
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Scenario You need to create a software class that represents a warrior in a game program. The warrior with have a health score (0 to 100), a strength score (1 to 5) and an intelligence score (1 to 5). The warrior will be used in battles and can take hits that will decrease health. The warrior is dead if his health score is 0. Requirements The warrior class should have these private fields: health, name, strength and intelligence. Create a constructor that takes no arguments. Default the warriors name to "unknown", health to 100, strength to 3, and intelligence to 3. Create a constructor that takes warrior name, strength and intelligence. Create a toString() method that returns a string formatted like this (example): Warrior health is: The angle brackets would be replaced with appropriate value. Create a method called isAlive() that returns true if the warrior is alive. Create a method called takeHit(). Generate a random number between 0 and 50. Decrease the warrior's health by this amount. Do not let health go below 0. Create a warrior driver class that does this: Asks for warrior's name. Creates the warrior (you can decide what the strength and intelligence should be). Repeatedly call make the warrior take a hit until the warrior is dead. The output should be similar to this (choose your own warrior name!): Warrior name? Troll King Troll King is hit! Warrior Troll Kinghealth is: 89 Troll King is hit! Warrior Troll Kinghealth is: 78 Troll King is hit! Scenario You need to create a software class that represents a warrior in a game program. The warrior with have a health score (0 to 100), a strength score (1 to 5) and an intelligence score (1 to 5). The warrior will be used in battles and can take hits that will decrease health. The warrior is dead if his health score is 0. Requirements The warrior class should have these private fields: health, name, strength and intelligence. Create a constructor that takes no arguments. Default the warriors name to "unknown", health to 100, strength to 3, and intelligence to 3. Create a constructor that takes warrior name, strength and intelligence. Create a toString() method that returns a string formatted like this (example): Warrior health is: The angle brackets would be replaced with appropriate value. Create a method called isAlive() that returns true if the warrior is alive. Create a method called takeHit(). Generate a random number between 0 and 50. Decrease the warrior's health by this amount. Do not let health go below 0. Create a warrior driver class that does this: Asks for warrior's name. Creates the warrior (you can decide what the strength and intelligence should be). Repeatedly call make the warrior take a hit until the warrior is dead. The output should be similar to this (choose your own warrior name!): Warrior name? Troll King Troll King is hit! Warrior Troll Kinghealth is: 89 Troll King is hit! Warrior Troll Kinghealth is: 78 Troll King is hit!
Expert Answer:
Related Book For
Corporate Finance
ISBN: 978-0077861759
10th edition
Authors: Stephen Ross, Randolph Westerfield, Jeffrey Jaffe
Posted Date:
Students also viewed these programming questions
-
"internet radios" for streaming audio, and personal video recorders and players. Describe design and evaluation processes that could be used by a start-up company to improve the usability of such...
-
CANMNMM January of this year. (a) Each item will be held in a record. Describe all the data structures that must refer to these records to implement the required functionality. Describe all the...
-
A clinical study is established to determine if the results of a screening stress test can be used as a predictor of the presence of heart disease. The study enrolls 100 participants who undergo a...
-
(a) Draw all the Kekulé structures of anthracene and phenanthrene. (b) Propose mechanisms for the two additions shown. (c) Most of the additions of bromine to double bonds gave entirely anti...
-
Which bond in Exhibit 1 most likely has the lowest effective convexity? A. AI bond B. BI bond C. CE bond Jules Bianchi is a bond analyst for Maneval Investments, Inc. Bianchi gathers data on three...
-
For a given current loop, a rectangular geometry can make calculations more convenient than a circular geometry. How would the magnetic field from a small square current loop compare with that from a...
-
Chocolate Bars, Inc. (CBI), manufactures creamy deluxe chocolate candy bars. The firm has developed three distinct products: Almond Dream, Krispy Krackle, and Creamy Crunch. CBI is profitable, but...
-
11. An incompressible liquid is kept in a container having a weightless piston with a hole. A capillary tube of inner radius 0.1 mm is dipped vertically into the liquid through the airtight piston...
-
This is an individual, two part assignment. Review the following scenario, and then follow the instructions below to complete Part 1 and Part 2 of the assignment. Assume that you have been hired as a...
-
Give some examples to show the differences between XML and HTML.
-
For many years, health care organizations, as well as traditional businesses, have been frustrated that high customer satisfaction. scores do not necessarily lead to higher levels of profitability or...
-
Write a method public static clearAllDirectories(Path dir) that removes all files and all subdirectories from a directory. Be very careful when testing it!
-
What happens if you try to write to a random access file that you opened only for reading? Try it out if you dont know.
-
Having just been recruiting to a new com- munity in Florida as the senior vice presi- dent for marketing, a review of the demographics made you realize the com- munity was slightly older than you had...
-
You are making toast using a 1200 W toaster, and would like to know how much it costs to make a slice of toast. Assume it take 1 minute to make the toast and that the electricity costs 9 cents per...
-
The Ranch 888 Noodle Company sells two types of dried noodles:ramen, at $6.50 per box, and chow fun, at $7.70 per box. So farthis year, the company has sold a total of 110,096 boxes ofnoodles,...
-
The wreck of the S.S. Central America waited 130 years at the bottom of the ocean for someone to come along and claim its trove of gold. Thomas G. Thompson, funded by a multitude of investors, was...
-
Bert C. Roberts Jr. was chairman of WorldComs board of directors. Immediately before that, he had been chairman of MCI, which WorldCom acquired on September 14, 1998, in a transaction valued at...
-
Bernardino Santos-Rodiguez was piloting a boat owned by his friend, Raul Viera-Torres, in waters near Guayama, Puerto Rico. The boat was equipped with a hydraulic steering system manufactured by...
Study smarter with the SolutionInn App