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
-
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...
-
(a) If the kinetic energy of a particle is tripled, by what factor has its speed increased? (b) If the speed of a particle is halved, by what factor does its kinetic energy change?
-
Employees at Rayon Enterprises earn one day a month of vacation compensation (twelve days total each year). Vacation compensation is paid at an hourly rate of $45, based on an eight-hour work day....
-
Daphne Brown-Wright worked as a teacher for East St. Louis School District 189 from 1975 until 1998 and then returned as an administrator from 2002 until 2012, thus serving the District for 33...
-
The stockholders equity accounts of G.K. Chesterton Company have the following balances on December 31, 2008. Common stock, $10 par, 300,000 shares issued and outstanding ... $3,000,000 Paid-in...
-
1. Find the mass of 3.02 x 10 19 atoms of arsenic, which has a molar mass of 74.9 g/mol. 2. Gold has a molar mass of 197 g/mol. (a) How many moles of gold are in a 3.03 g sample of pure gold? (b) How...
-
Several AI winters, or rapid collapses in levels of economic and academic activity (and media interest) associated with AI, have occurred. Describe the causes of each collapse and of the boom in...
-
A machine was purchased on 1 April 20X0 for $120,000. It was estimated that the asset had a residual value of $20,000 and a useful life of 10 years at this date. On 1 April 20X2, the residual value...
-
A 624 thin hoop with radius 12.2cm Spins about its center. The hoop initially turns at a rate of 229.8 rad/s but comes to rest after turning through 25 radians, what is the magnitude of the net...
-
1. Calculate the speed of an 8.0 104 kg airliner with a kinetic energy of 1.1 10 J. 2. What is the speed of a 0.145 kg baseball if its kinetic energy is 109 J? 3. Two bullets have masses of 3.0 g...
-
Alice, Bob and Carol use the the elliptic curves encryption scheme to communicate, and use the elliptic curve digital signature algorithm (ECDSA) to sign all messages they send. They decided on the...
-
Vector A, of magnitude 376.8 and direction 0=214.04, has x- and y-components - 312.2 and -210.9. See the figure to the right. Change 214.04 to 180.00 and find the components of the vector. The...
-
Packages and libraries functions JAVA ONLY Instructions For this assignment, you need to create a program that allows the user to do some basic math functions. First, ask the user if they would...
-
How would the risk of exposure to radioactive substances be different if nuclear radiation followed an inverse square law?
-
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...
-
In defining asset classes as part of the strategic asset allocation decision, pairwise correlations within asset classes should generally be: A. Equal to correlations among asset classes. B. Lower...
-
Tactical asset allocation is best described as: A. Attempts to exploit arbitrage possibilities among asset classes. B. The decision to deliberately deviate from the policy portfolio. C. Selecting...
-
The timing of payouts for property and casualty insurers is unpredictable (lumpy) in comparison with the timing of payouts for life insurance companies. Therefore, in general, property and casualty...
Study smarter with the SolutionInn App