Java代写 | Game代写 | OOP代写 – Object-Oriented Programming in an Adventure Game

Java代写 | Game代写 | OOP代写:这是一个利用java进行面向对象编程的题目
Description
In this assignment, you will refactor some existing code (doing this is common in the real world); more specifically, you will write and use a number of custom Java classes. The code that you will refactor is for a game called The Adventure Game. Store your updated “Adventure Game” code in a file named ​AdventureGameWithObjects.java​. Store your classes in the files Player.java​, ​Enemy.java​, and ​Weapon.java​.
The focus of this assignment is: (1) defining classes; and (2) using objects.
The Adventure Game
The Adventure Game​ is a simple text-based roleplaying game. You should begin this assignment by reading the description of the game (in ​Adventure-Game-Description.pdf​), and then you should play the game by compiling and running ​AdventureGame.java​.
After playing the game a few times, read over the code in ​AdventureGame.java​. Notice that the player and enemies are represented by a collection of ​primitive variables​. Your primary task for this assignment is to refactor the code so that the player, enemies, and weapons are represented by ​objects​.
Your Tasks
Below are your main tasks for this assignment.
1. Add three new features to the original Adventure Game (feature list is below).
2. Implement the player, enemies and weapons in the game as objects (class descriptions
are given below).
New Features
You will add three new features to the original game.
1. Improved Pacing
Improve the pacing of the game by prompting the player to hit a key after each minion (i.e. Goblin/Skeleton) fight. So when the player battles multiple minions, instead of simulating all the fights and printing all the outputs together, the first fight will be simulated and its results printed, but then the user will be prompted to hit the Enter key to continue to the next fight.

2. A New, Powerful Weapon
In addition to the option of choosing a Healing Potion or a Ring of Strength, present the player with a third option: Staff of Power.
Weapon Name: Staff of Power Damage: ​5 – 9
3. Variable Number of Goblins/Skeletons
The number of goblins will be a random number in the range 2 – 5. The number of skeletons will be a random number in the range 3 – 7.
Class Descriptions
★ Player
○ Attributes
■ name(String)
■ hitPoints(int) ■ strength(int) ■ weapon(Weapon)
○ Methods
■ Player(_name,_hitPoints,_strength,_weapon)
● This method is the only constructor of the ​Player​ class. Pass to this method a ​String​ for the name, an ​int​ for the initial hit points, an ​int​ for the strength attribute, a reference to a ​Weapon object for the player’s weapon.
■ getName()
● This method should return the name as a ​String​.
■ getHitPoints()
● This method should return the number of hit points.
■ increaseHitPoints(_pointIncrease)
● This method will add the number of points passed to the hit points.
■ decreaseHitPoints(_pointDecrease)
● This method will subtract the number of points passed from the hit
points.
■ getStrength()
● This method should return the value of the strength attribute. ■ increaseStrength(_strengthIncrease)
● This method will add the passed value to the player’s strength attribute.

★ Enemy
○ Attributes
less; otherwise, it will return ​false​.
■ setWeapon(_weapon)
● This method will set the player’s weapon to be the ​Weapon​ object
that is passed to the method. ■ attack(_enemy)
● This method will simulate an attack against the ​Enemy​ object that is passed to the method.
■ battleMinion(_enemy)
● This method will simulate a battle against the ​Enemy​ object that is
passed to the method, where that object is a ​goblin​ or s​ keleton​. ■ battleWizard(_enemy)
● This method will simulate a battle against the Enemy object that is passed to the method, where that object is a ​wizard​.
■ isDefeated()
● This method will return ​true​ if the player’s hit points value is ​0​ or
■ name(String)
■ hitPoints(int) ■ strength(int) ■ weapon(Weapon)
○ Methods
■ Enemy(_name,_hitPoints,_strength,_weapon)
● This method is the only constructor of the ​Enemy​ class. Pass to this method a ​String​ for the name, an ​int​ for the initial hit points, an ​int​ for the strength attribute, a reference to a ​Weapon object for the enemy’s weapon.
■ getName()
● This method should return the name as a ​String​.
■ getHitPoints()
● This method should return the number of hit points.
■ resetHitPoints()
● This method resets the hit points to 25 and should only be used
for goblin or skeleton enemies.
■ decreaseHitPoints(_pointDecrease)
● This method will subtract the number of points passed from the hit points.
■ getStrength()
● This method should return the value of the strength attribute.
■ attack(_player)
● This method will simulate an attack against the ​Player​ object
that is passed to the method.

■ isDefeated()
● This method will return ​true​ if the player’s hit points value is ​0​ or
less; otherwise, it will return ​false​. ■ getNumGoblins()
● This is a ​static​ method that will return a random ​int​ that is in the range 2 – 5.
■ getNumSkeletons()
● This is a ​static​ method that will return a random ​int​ that is in the
range 3 – 7.
★ Weapon
○ Public Constants
■ Add all of the weapon-damage-related constants (e.g. SHORT_SWORD_MIN​) to this class as public, static constants. You will then be able to reference a constant in your main method by preceding the name of the constant with the name of the class (e.g. Weapon.SHORT_SWORD_MIN​).
○ Attributes
■ name(String)
■ minDamage(int)
■ maxDamage(int) ○ Methods
■ Weapon(_name,_minDamage,_maxDamage)
● This method is the only constructor of the Weapon class. Pass to
this method a ​String​ for the name, an ​int​ for the minimum
damage, and an ​int​ for the maximum damage. ■ getName()
● This method should return the name as a ​String​. ■ getMinDamage()
● This method will return the minimum damage of the weapon. ■ getMaxDamage()
● This method will return the maximum damage of the weapon. ■ getDamage()
● This method will return a random ​int​ that is in the range of the minimum and maximum damage values.

Programming Requirements
● Define and properly use all of the classes described above.
○ Attributes for the player, enemies and weapons must be stored in objects of the proper class, not in primitive variables or arrays.
○ Every method of every class should be called ​at least once​ in the ​main​ method of your ​AdventureGameWithObjects.java ​file​ ​or in one of your other classes (with the exception of the method ​resetHitPoints​).
● Include a multi-line comment at the top of your source file that includes your name, the class (CS401), the semester (Spring 2018), and the assignment name (Assignment 5), with each item on its own line.
● Use good programming style. Specifically, in addition to the multi-line comment described above, ​include at least 5 comments in each class file​.
● Global variables are prohibited (except for constants)​.
● The gameplay should be the same as that in the original Adventure Game with the
addition of the added features. See the sample output for an example.

发表评论

电子邮件地址不会被公开。 必填项已用*标注