How to run the program?

Step1: open Start(開始)
Step2: open Run(執行)
Step3: input "cmd" into the textbar and then press "Enter"
Step4: Compile both files (e.g.javac Compiler*.java) and run file (e.g . java CompilerTest).

11月 19, 2007

Lingnan Fighting II

This is the second version of Lingnan Fighting. It is a different from the first version. There are three classes: BossPlayer, FightersUniverse and Player. Also, BossPlayer class inherits Player class. And the FightersUniverse is the main program.

In the other hand, there are four player here. Two of the player are the boss. That means the defense and attackment of boss is more than that of other players.
The rule:
There are four players, each with an initial power of 10. Two of them are ordinary players and the other two are boss players. In each round, one player is selected by random to attack another random player.

If a player chosen is already dead in previous rounds, or a player is selected to attack himself/herself, then select another player.

The rules of attack are the same as in the previous homework, except for the following:
Boss players are more resistant to attacks. When they lose an attack, they only lose half the amount than an ordinary player. For example, consider that boss player Janice and ordinary player Ho Yin have 40 and 60 points of power respectively before the attack. If Ho Yin wins the attack, then Janice would only lose half of the power difference (i.e. 0.5*difference).
Boss players gain double the power difference on win. For example, if boss player Janice wins in the above example, she should gain 2*difference.

Sample of output:



You can download the file here:
BossPlayer: BossPlayer.java
Player: Player.java
FightersUniverse: FightersUniverse.java

Or you can download the source code as a zip file: FightersUniverse.rar

沒有留言: