CS161 Introduction to Computer Science II Lab 2 - Party Points: 35 Goals By completing this...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
CS161 Introduction to Computer Science II Lab 2 - Party Points: 35 Goals By completing this Lab, you will review and gain experience using UML diagrams, arrays, random numbers, object aggregation, user interaction via the console, and basic testing. Create an Eclipse project named "Lab2_FirstNameLastName". (22 pts) Implement an application with the following description: Create three classes: Hero, Party, and PartyTest. ● CS161 Introduction to Computer Science II ● ● The Hero class contains data related to a Hero in a video game. Implement the Hero class according to the following UML diagram: Hero Data fields -name: String -hClass: String -level: int -experience: int -MAX LEVEL: int -LEVELS: int[10] Methods +Hero (name: String) Contains the name of the Hero Contains the class of the Hero (Be careful, class is a java keyword!) Contains the level of the Hero +toString() Contains the experience of the Hero Constant static int containing the max level possible. Set it to 10. +Any accessor methods you need +Any mutator methods you need +setRandomLevel() :void :String Constant static int array containing the numbers {5, 10, 15, 20, 30, 40, 50, 75, 100}. These are the experience amounts required to proceed from level 1 to 2 (5 experience), 2 to 3 (10 experience), etc. up to max level. +gainExperience (experience: int) :void Set the name to given value and set class to empty String, level to 1, and experience to 0. Return the name, class, or level. Set the name, class, or level. Set the level to a random level between 1 and 10. Increase the experience of the Hero. If the experience reaches or passes the maximum for the Hero's current level, increase the level by 1, reset experience to 0, and add any "leftover" experience. Return a String containing the information about the hero such as name, class, level, experience. Make it easily readable when printed using newline and/or tab characters. CS161 Introduction to Computer Science II ● The Party class contains an array of Hero's to manage the current party. Implement the Party class according to the following UML diagram: Data fields -Heroes: Hero[3] Methods +Party() +addHero(index: int, hero: Hero) :void +removeHero(index: int) :Hero +getHero(index: int) :Hero +gainExperience(experience: int) +toString() ● ● ● :String ● Party Contains the Hero's in the current party. Implement PartyTest class with the following description. The PartyTest class has the main method that must do following: O O Initialize the empty Hero array to hold 3 Hero's. ■ Add a Hero to the current party at the given index. If there is an existing Hero at the index, replace it. Remove and return the Hero from the given index (set the array index to null to "remove"). Return the Hero of the desired index. Increase the experience of all the Hero's in the Party. Hint: Use each Hero's gainExperience method Print out the current Party's data. Hint: Use each Hero's toString method. Create a Party object. Create a String array of valid class names. O You can decide what classes you allow the user to choose from. Create 4 or more Hero objects with names that you decide on. O You can think of your own names or have fun with a random name generator: https://www.name-generator.org.uk/ Using the console, list the available classes and ask the user to choose a class for each Hero. If the user enters an invalid class, inform them to try again. Set the class of each Hero. CS161 Introduction to Computer Science II ● Test the various methods of the Party and Hero classes. Here are some examples: Use the setRandomLevel method on one of the Hero's. O O Put 3 Hero's in the party. O Sample Output Give them some experience and make sure they are leveling up properly (print their data to prove it). Mix up the party by swapping in the unused Hero. ■ Give the party some more experience and print the party's data again. The available classes are: warrior wizard thief clown banker Enter the class for Gumbledalf wizard Enter the class for Bobby banker Enter the class for Tyrone tyroneasaurus That is not a valid class, but I admire your creativity. Please enter a valid class for Tyrone thief Enter the class for Ophelia warrior Gumbledalf's level was randomized to 9 Gumbledalf was added to the party. Bobby was added to the party. Tyrone was added to the party. The party gained 15 experience. Bobby is now level 2! Bobby is now level 3! Tyrone is now level 2! Tyrone is now level 3! Party Gumbledalf the wizard is level 9 with 15 experience Bobby the banker is level 3 with experience Tyrone the thief is level 3 with experience Gumbledalf was removed from the party. Ophelia was added to the party. The party gained 45 experience. Ophelia is now level 2! Ophelia is now level 3! Ophelia is now level 4! CS161 Introduction to Computer Science II Bobby is now level 4! Bobby is now level 5! Tyrone is now level 4! Tyrone is now level 5! Party Ophelia the warrior is level 4 with 15 experience Bobby the banker is level 5 with 10 experience Tyrone the thief is level 5 with 10 experience Submit: Submit the Eclipse project folder containing source code and all associated class files by the due date. All source code should be properly documented. CS161 Introduction to Computer Science II Lab 2 - Party Points: 35 Goals By completing this Lab, you will review and gain experience using UML diagrams, arrays, random numbers, object aggregation, user interaction via the console, and basic testing. Create an Eclipse project named "Lab2_FirstNameLastName". (22 pts) Implement an application with the following description: Create three classes: Hero, Party, and PartyTest. ● CS161 Introduction to Computer Science II ● ● The Hero class contains data related to a Hero in a video game. Implement the Hero class according to the following UML diagram: Hero Data fields -name: String -hClass: String -level: int -experience: int -MAX LEVEL: int -LEVELS: int[10] Methods +Hero (name: String) Contains the name of the Hero Contains the class of the Hero (Be careful, class is a java keyword!) Contains the level of the Hero +toString() Contains the experience of the Hero Constant static int containing the max level possible. Set it to 10. +Any accessor methods you need +Any mutator methods you need +setRandomLevel() :void :String Constant static int array containing the numbers {5, 10, 15, 20, 30, 40, 50, 75, 100}. These are the experience amounts required to proceed from level 1 to 2 (5 experience), 2 to 3 (10 experience), etc. up to max level. +gainExperience (experience: int) :void Set the name to given value and set class to empty String, level to 1, and experience to 0. Return the name, class, or level. Set the name, class, or level. Set the level to a random level between 1 and 10. Increase the experience of the Hero. If the experience reaches or passes the maximum for the Hero's current level, increase the level by 1, reset experience to 0, and add any "leftover" experience. Return a String containing the information about the hero such as name, class, level, experience. Make it easily readable when printed using newline and/or tab characters. CS161 Introduction to Computer Science II ● The Party class contains an array of Hero's to manage the current party. Implement the Party class according to the following UML diagram: Data fields -Heroes: Hero[3] Methods +Party() +addHero(index: int, hero: Hero) :void +removeHero(index: int) :Hero +getHero(index: int) :Hero +gainExperience(experience: int) +toString() ● ● ● :String ● Party Contains the Hero's in the current party. Implement PartyTest class with the following description. The PartyTest class has the main method that must do following: O O Initialize the empty Hero array to hold 3 Hero's. ■ Add a Hero to the current party at the given index. If there is an existing Hero at the index, replace it. Remove and return the Hero from the given index (set the array index to null to "remove"). Return the Hero of the desired index. Increase the experience of all the Hero's in the Party. Hint: Use each Hero's gainExperience method Print out the current Party's data. Hint: Use each Hero's toString method. Create a Party object. Create a String array of valid class names. O You can decide what classes you allow the user to choose from. Create 4 or more Hero objects with names that you decide on. O You can think of your own names or have fun with a random name generator: https://www.name-generator.org.uk/ Using the console, list the available classes and ask the user to choose a class for each Hero. If the user enters an invalid class, inform them to try again. Set the class of each Hero. CS161 Introduction to Computer Science II ● Test the various methods of the Party and Hero classes. Here are some examples: Use the setRandomLevel method on one of the Hero's. O O Put 3 Hero's in the party. O Sample Output Give them some experience and make sure they are leveling up properly (print their data to prove it). Mix up the party by swapping in the unused Hero. ■ Give the party some more experience and print the party's data again. The available classes are: warrior wizard thief clown banker Enter the class for Gumbledalf wizard Enter the class for Bobby banker Enter the class for Tyrone tyroneasaurus That is not a valid class, but I admire your creativity. Please enter a valid class for Tyrone thief Enter the class for Ophelia warrior Gumbledalf's level was randomized to 9 Gumbledalf was added to the party. Bobby was added to the party. Tyrone was added to the party. The party gained 15 experience. Bobby is now level 2! Bobby is now level 3! Tyrone is now level 2! Tyrone is now level 3! Party Gumbledalf the wizard is level 9 with 15 experience Bobby the banker is level 3 with experience Tyrone the thief is level 3 with experience Gumbledalf was removed from the party. Ophelia was added to the party. The party gained 45 experience. Ophelia is now level 2! Ophelia is now level 3! Ophelia is now level 4! CS161 Introduction to Computer Science II Bobby is now level 4! Bobby is now level 5! Tyrone is now level 4! Tyrone is now level 5! Party Ophelia the warrior is level 4 with 15 experience Bobby the banker is level 5 with 10 experience Tyrone the thief is level 5 with 10 experience Submit: Submit the Eclipse project folder containing source code and all associated class files by the due date. All source code should be properly documented.
Expert Answer:
Answer rating: 100% (QA)
Heres a basic outline of how you could implement the three classes described Hero Class Attributes n... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
Sanford Turbines of Ogden, Utah designs and manufactures industrial gas turbines for onshore and offshore electrical power generation systems. All compressor components of the turbine systems are...
-
Chips and Partners Requirement 1 Actual CostingNormal Costing Direct Cost Rate (DCR)Actual RateActual Rate Professional Labor Rate (DCR)5858 Indirect Cost RateActual RateBudgeted Rate Professional...
-
Ortiz Corporation runs two convenience stores, one in Connecticut and one in Rhode Island. Operating income for each store in 2014 is as follows: (Click to view the operating income for the stores.)...
-
Gothic Kings Ltd. Is a 100% owned subsidiary of Hadrian Inc. Gothic has been profitable in the past but incurred a loss for the year ended December 31, 20X3. Hadrian has indicated that if Gothic...
-
Which influence tactics are most likely to result in target commitment?
-
Management Information Systems (MIS) What are complementary assets? Why are complementary assets essential for ensuring that information systems provide genuine value for an organization? Strategic...
-
Identify the four common operating cycles of business activity.
-
On July 1, 20--, Susan Woodworth and Barbara Holly combined their two businesses to form a partnership under the firm name of Woodworth and Holly. The balance sheets of the two sole proprietorships...
-
Hello, I would like to receive the answer for this problem, regarding Privalias Case Study from the university of EASE: c. Finally, you want to find out how many campaigns each internal resource can...
-
Pauley, Inc., pays its employees' weekly wages in cash. A supplementary payroll sheet that lists the employees' names and their earnings for a certain week is shown below. Complete the payroll sheet...
-
Suggest factual, conceptual, procedural, and metacognitive statements for the following: I can process financial data for up to 10 million dollars in revenue sales; Well enough to effectively manage...
-
2 :t t 2 t t -139.6.deg 0.02 /m C a) Draw the electric field lines. < 7 AD Fig. 24 1 7 -16.5 V -7.4 V b) Label the locations where the electric field is equal to zero. Explain the results. 2 4.5 V c)...
-
Take a "real life" negotiation or dispute resolution experience from your own life or from the experience of others (that you read about in the news, for example). It might have occurred in the past,...
-
Compare/contrast these forms. (Suggestion: At a minimum, name at least one advan- tage and disadvantage for each.) 3. It may be possible to reduce setup costs when a company orders several types of...
-
Tom purchased a ticket from a scalper on a street corner to watch his favorite professional baseball team. He walked into the stadium and purchased a beer and a hotdog and took his seat in the...
-
Pam took the week off work due to a scheduled surgery with Dr. Holly to have her appendix removed. The surgery took place at Bennett Medical Center. Dr. Holly was contracted with several hospitals...
-
A firm has sales of $500,000, a debt-to-equity ratio of one, and total assets of $1,000,000. If its profit margin is 5%, what is the firms return on equity?
-
As economic conditions change, how do banks adjust their asset portfolio?
-
Carol Harris, Ph.D, CPA, is a single taxpayer and she lives at 674 Yankee Street, Durham, NC 27409. Her Social Security number is 793-52-4335. Carol is an Associate Professor of Accounting at a local...
-
The following additional information is available for the Dr. Ivan and Irene Incisor family from Chapters 1-4. Ivan and Irene paid the following in 2012 (all by check or can otherwise be...
-
John Williams (age 42) is a single taxpayer, and he lives at 1324 Forest Dr., Reno, NV 89501. His Social Security number is 555-94-9358. John's earnings and withholdings as the manager of a local...
-
The supply of a good _________ if the price of one of its substitutes in production rises.
-
The supply of a good _________ if the price of one of its substitutes in production falls.
-
A situation where quantity demanded is greater than quantity supplied is called a(n) _________.
Study smarter with the SolutionInn App