By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,370 Members | 1,188 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,370 IT Pros & Developers. It's quick & easy.

Urgent......need help solving java problem

P: 1
i have a java prob, and i have to solve it fast, but i'm just getting to know it, so plz help me solve it with full code completed, thanks so much. the prob is to create a monter fight and there is the description:
The monsters are of a very strange kind, called "Bigmon". They have some basic characteristics, like attack and defense power, life points, a name, and a bonus factor that is used in special occasions.
In this initial phase of the project, we will need to develop 3 classes, with 3 different purposes.
1. A Bigmon class, that allows us to create instances of our virtual monsters.
2. A FightMenu class, that shows the main menu of the game, and is the starting point of the
application.
3. A FightTest class, that has some functionality to allow us an easy way to run some automated actions in our program, to verify that our changes don't introduce errors.

Bigmon class
Our virtual monsters have some associated information:
● name
● life points: when they reach 0, the Bigmon is dead, and needs to be healed or it can not fight anymore. We also need to remember what is the maximum life points of each Bigmon monster.
● attack power: between 0 and 18.
● defense power: between 0 and 18.
● bonus: between 1 and 3, with decimals. Default value is 1.2. In special occasions, our Bigmon can have extra power for fighting. See explanation below.
Our Bigmon class must have several methods:
1. Accessors (getters) and mutators (setters) for all relevant variables.
2. Two constructors, one without parameters that creates a default Bigmon, with very average values (not too strong, not too weak); and one with parameters for name, max points, attack power and defense power.
3. Functions (methods that are not of type void) that calculate the value of an attack attempt and defense attempt, taking the bonus into account.
4. A function that returns a one line summary of the status of the Bigmon: name, life points, max points, attack power, defense power.
How Bigmons Fight
When 2 Bigmons fight, they take turns exchanging attacks. Here is the process:
● At the beginning of the fight, one Bigmon is chosen randomly to start attacking.
● The attacking Bigmon gets a random number between 0 and its attack power.
Example: if its attack power is 14, the random number is between 0 and 14.
● The defending Bigmon gets a random number between half of its defense power and its defense power.
Example: if its defense power is 16, the random number is between 8 and 16.
● If the attacking Bigmon has the higher number, the defending Bigmon loses as many life points as the difference between the numbers.
● If the defending Bigmon has the higher number, nothing happens.
● There are 2 exceptions to this general rule:
○ If the attacking Bigmon gets lucky, and his random number is the maximum he can get, he always hits. The defending Bigmon loses life points: 50% of the attack power of the attacking Bigmon. (In our example, 7 points.)
○ If the attacking Bigmon is very unlucky and gets a 0, the attack backfires! The attacking Bigmon loses life points: 50% of his own attack power!
● Now the defending Bigmon will attack, and the attacking Bigmon defends.
● The Bigmons attack each other in a loop until one of them has 0 life points.
There is a Bonus system that also changes the progress of a fight. See the explanation below.
You should notice that the Fight process is going to make you add several methods to the Bigmon class if you want to keep the code for the fight more clear. Try to avoid putting functionality that belongs to the Bigmon class in the FightMenu class.
Bonus System
When a Bigmon has only 20% of his maximum life points, he has a 30% chance of transforming into a SuperBigmon! If he gets lucky, its attack and defense power are multiplied by the bonus, until the end of the fight, and he recovers 20% of his life points. Its name is also written differently, as explained below.
Example: a Bigmon called Kapuche, with maximum life points 40, attack power 16, defense power 12, bonus 1.2. During a fight he has only 7 life points (less than 8 points, 20% of 40). At the beginning of each fight round, he can transform into "|</\puch3". If he is lucky and transforms, his attack power becomes 19 (16 * 1.2, no decimals), defense 14 (12 * 1.2), and recovers 8 life points. All this, except the life points, is back to normal at the end of the fight. A Bigmon can be very dangerous when he is almost dead!!
SuperBigmon Names
As you have seen in the example, when a Bigmon is in SuperBigmon form, his name is printed differently. We are going to use a small part of the “L33t” way of spelling, as described here:

Letter in Normal form - Letter in Super form
A - /\
a - @
e or E - 3
f or F - ph or Ph
k or K - |<
m or M - /V\
n or N - |\|
o or O - 0 (the number zero)
s or S - 5
v or V - \/
w or W - \X/
You need to be able to modify any word in the way described in the table, because we will allow the user to type any name that he/she wants for the Bigmon. We will also have a way to generate random Bigmon names.
Keep in mind that we only need to use the SuperBigmon name when the Bigmon is in “Super” form, exactly at the same time as his attack and defense power are affected by the bonus.
Hint: use the StringBuilder, to give you more flexibility replacing text.

FightTest class
The FightTest class has one main method, that does the following actions:
● Create 2 random Bigmons.
● Display their information on the screen.
● Displays their SuperBigmon names.
Only display the names! The Bigmons must be in normal form for the next step!
● Starts a fight between them.
It is important that you find a way to make the FightTest class use the fight method of the FightMenu class, and not have its own copy of the fight code!!
FightMenu class
This is the actual Game class, which starts the proper game play in our program. When you start its
main method, it will create an instance of the FightMenu class, and run a method of this instance
that prints this on the screen:
* Bigmon Battle! *********************
1. Create a new Bigmon
2. List all the Bigmons
3. Delete a Bigmon.
4. Heal a Bigmon.
5. Delete all dead Bigmons.
6. Fight! (Bigmon vs. Bigmon)
0. Exit.
***************************************
Your Choice: _
The options should work as described here:
1. Create a new Bigmon: the user then has the option to create a random Bigmon, or to enter
the information manually.
2. List all the Bigmons: the FightMenu class has an array of 10 Bigmons. Here the program will print a list with the information of all of them. Obviously, when you use option 1, the new Bigmon is stored in a free position of this array.
3. Delete a Bigmon: the user chooses a number between 0 and 9, and that position in the array is made empty (null).
4. Heal a Bigmon: the user chooses a number between 0 and 9, and if that position in the array is not empty (!= null), the Bigmon recovers all the life points, and is back in normal form.
5. Delete all dead Bigmons: go through the array, making each position with a dead Bigmon (life points are 0) empty.
6. Fight! The user chooses 2 positions of the array, and a fight starts.
Hint: The menu is really easy. You probably need to use a loop that repeats constantly while the user doesn't enter “0” with the keyboard.
Apr 3 '08 #1
Share this Question
Share on Google+
1 Reply


10K+
P: 13,264
We don't do people's assignments here. See the help link at the top of this page for more details.
You have to do it yourself. We'll only help if we can see that you are doing something.
Apr 3 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.