[Solved] 2110215PROG-Midterm 3

$25

File Name: 2110215PROG-Midterm_3.zip
File Size: 197.82 KB

SKU: [Solved] 2110215PROG-Midterm 3 Category: Tag:
5/5 - (1 vote)
  1. Instructions
    • Create Java Project named 2110215_Midterm_Q3 in your workspace.
    • Copy all folders in Q3.zip to your project directory src folder.
    • You are to implement the following classes (details for each class are given in section 4.)
      1. Penguin (package penguin)
      2. FighterPenguin (package penguin)
      3. ElementalPenguin (package penguin)
    • You also need to create a UML Diagram including the classes Penguin, FighterPenguin, and ElementalPenguin from the package penguin. (This is worth 2 points.) Save it as picture in the folder of package penguin.
    • JUnit for testing is in package test.
    • To submit:
      1. go to src folder that you actually do the coding for this question.
      2. Zip this questions src folder. Name it YOUR-ID_Q3.zip (for example,

6332112121_Q3.zip)

  1. Submit the zipped file as an assignment on MyCourseville.
  1. Problem Statement: Penguin Impact

You are hired by MemeHoyo to finish the code for the game Penguin Impact after the previous programmer was fired for hacking Penguin Gems into his own account. Your task is to create new Penguin classes that supports PvP combat, including the elemental system.

The characters in this game are Penguins. There are NPC Penguins that has no ability to fight, Fighter Penguins who has a power level and can attack other Penguins, and Elemental Penguins who has elemental advantage and disadvantages over other Penguins with elements.

There are three elements in this game. Fire, Water, and Snow. Refer to the chart above for elemental advantage information. Fire beats Snow, Snow beats Water, and Water beats Fire. Elemental advantage allows a Penguin to deal double damage, while elemental disadvantage gives them a half damage penalty. Elemental Penguins do not gain advantage or disadvantage over non-elemental Penguins or Elemental Penguins of the same type.

  1. Implementation Details

The class packages are summarized below. Note that only important methods that you either need to write and methods that you need to complete this question are listed below.

4.1 package penguin

4.1.1. public class PenguinUtil /*ALREADY PROVIDED*/

This class contains useful functions for creating your program.

  • Variables

None.

  • Methods
Method Description
+ String getTypeString(ElementalPenguin penguin) Static method. Returns a shorthand String of the input Penguins element. Used for ElementalPenguins toString.
+ String makeToString(Penguin p) Static method. Returns a Penguin formatted as string. Used for Penguins toString, FighterPenguins toString, and ElementalPenguins toString.
+ String makeSpeech(Penguin p) Static method. Returns a formatted speech string. Used for Penguins getSpeech.

4.1.2. public enum PenguinType /*ALREADY PROVIDED*/

This enum contains the values that can be used to initialize ElementalPenguin. There are three enum types here: PenguinType.FIRE, PenguinType.SNOW, PenguinType.WATER. 4.1.3. public class Penguin /* You must implement this class from scratch*/

This class represents a Penguin in the game world. This class will be used for noncombatant NPCs.

  • Variables
Variable Description
-String name The name of this Penguin.
-int hp The HP of this Penguin. If it reaches 0, it is defeated.
-int maxHp The max HP of this Penguin.
-String catchphrase This Penguins catchphrase that it will say in combat.
  • Methods
Method Description
+ Penguin(String name, int hp, String catchphrase) Constructor. Set variables to the given parameter values. maxHp is set to the value of hp. (The ordering of these parameter is important!)
Public getter/setter for everything For setMaxHp and setHp, if the input is less than 0, set the value to 0. For setHp, if the input is greater than maxHp, set the value to maxHp.
+ String toString() Returns this characters status. UsePenguinUtils makeToString for this.
+ String getSpeech() Returns this characters catchphrase. Use PenguinUtils makeSpeech for this.

Important: There are 3 methods in PenguinTest (package test) that cannot be tested until other classes are finished. They are originally commented out. Please uncomment them to test them when you finish other classes.

4.1.4. public class FighterPenguin /* You must implement this class from scratch*/

This class represents an extension of the base Penguin class that can attack. This class will be used for player characters and enemies.

  • Variables
Variable Description
-int pow The power level of this Penguin.
  • Methods
Method Description
+ FighterPenguin(String name, int hp, int pow,String catchphrase) Constructor. Use the super constructor to set other values, and set the pow to pow.
Public getter/setter for pow. For setPow, if the input is less than 0, set the value to 0.
+ int attack(Penguin target) Deals damage to the target. Reduce the target Penguins health by this Penguins pow, then return the damage dealt.
+ String toString() Returns this characters status. UsePenguinUtils makeToString for this.

Important: There are 2 methods in FighterPenguinTest (package test) that cannot be tested until other classes are finished. They are originally commented out. Please uncomment them to test them when you finish other classes.

4.1.4. public class ElementalPenguin /* You must implement this class from scratch*/

This class represents an extension of the base FighterPenguin class whose attacks have an elemental attribute.

  • Variables
Variable Description
-PenguinType type The elemental type of this Penguin. See the enum PenguinType for more information.
  • Methods
Method Description
+ ElementalPenguin(String name, int hp, int pow, PenguinType type, String catchphrase) Constructor. Use the super constructor to set other values, and set the type to type.
Public getter/setter for type.
+ int getElementalAdvantage(Penguin target) Returns 0 if this Penguin has no advantage or disadvantage over target Penguin. Returns 1 if this Penguin has elemental advantage over target Penguin. Returns -1 if this Penguin has elemental disadvantage over target Penguin. (Elemental advantage is explained in ProblemStatement, but to recap: Fire beats Snow, Snow beats Water, and Water beats Fire. If the target has no element or is the same element, there is no advantage or disadvantage.)
+ int attack(Penguin target) First, check for elemental advantage against the target. If there is elemental advantage, reduce the target Penguins health by this Penguins pow multiplied by 2. If there is elemental disadvantage, reduce the target Penguins health by this Penguins pow divided by 2 (rounded down). If there is no advantage or disadvantage, deal damage to target normally. Finally, return the damage dealt.
+ String toString() Returns this characters status. UsePenguinUtils makeToString for this.

4.2 package game

  • public class Test /*ALREADY PROVIDED*/

This class is for testing the objects you wrote. You can use this class to do whatever you want; it will not be checked.

  • public class GameApp /*ALREADY PROVIDED*/

This class contains a simulation of the PvP system that you can use to test the objects you wrote.

  1. Scoring Criteria

The scoring criteria is listed below. There are 3 JUnit files to test for the 3 files in the penguin package. The total score of this section is 38, which will be factored to a net score of 5. Note that some tests start off commented, and will have to be uncommented to be properly tested.

5.1 PenguinTest (Total: 12)

  • testConstructor (2)
  1. testSetName (1)
  2. testSetHp (1)
  3. testSetMaxHp (1)
  • testSetCatchphrase (1)
  1. testToString (uncomment after finishing ElementalPenguin) (1)
  • testGetSpeech (1)
  1. testNotFighter (uncomment after finishing FighterPenguin) (2)
  2. testNotElemental (uncomment after finishing ElementalPenguin) (2) 5.2 FighterPenguinTest (Total: 10)
  • testConstructor (2)
  1. testSetPow (1)
  2. testAttack (2)
  3. testToString (uncomment after finishing ElementalPenguin) (1)
  • testNotElemental (uncomment after finishing ElementalPenguin) (2)
  1. testInheritance (2)

5.3 ElementalPenguinTest (Total: 14)

  • testConstructor (2)
  1. testSetType (1)
  2. testGetElementalAdvantageFire (1)
  3. testGetElementalAdvantageSnow (1)
  • testGetElementalAdvantageWater (1)
  1. testGetElementalAdvantageElementless (1)
  • testGetElementalAdvantageSameElement (1)
  1. testAttackFire (1)
  2. testAttackSnow (1)
  3. testAttackWater (1)
  4. testToString (1)
  5. testInheritance (2)

5.4 UML Diagram of Penguin, FighterPenguin, and ElementalPenguin. Save the UML Diagram as png or jpg in the folder penguin. (2)

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] 2110215PROG-Midterm 3
$25