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).

12月 07, 2007

Octopus Simulator System

Octopus card is a rechargeable contactless stored value smart card used to transfer electronic payments in online or offline systems in Hong Kong. It is very popular in the world. It is also used for payment at convenience stores, supermarkets, fast-food restaurants, on-street parking meters, car parks, and other point-of-sale applications such as service stations and vending machines. Because of it, i would like to develop the Octopus Simulator System.
And it simulates the LRT octopus system. There are the source code of the System: Pass-in, Pass-out, Consultation and reload(增值). For the important, there is a CardHandler to handle all the method.
Sample of Output:







In this program, I also have an idea that if you want to reload your octopus card, you should play a game first, it is just a trick. That is Slot Machine. However, it is not installed at the reload.java. It is independent. Also, there would be a Graphical User Interface(GUI) for all program.

Firstly, you can download the file here:
CardHandler.java : CardHandler.java
reload.java: reload.java
Consultation.java: Consultation.java
passIn.java: passIn.java
passOut.java: passOut.java
tiger.java: tiger.java
Or you can download the source code as a zip file: project_octopusCardSystem.rar

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

10月 18, 2007

Lingnan Fighter

There is an exciting game!! It is called "Lingnan Fighter". In the game, there are two people that they will fight each other in random. You can see that there is a special thing:

If the "power difference" is zero before the attack (i.e. both players have the same power), then use 1 as the difference.

Sample of output:

Round 1
Player Ho Yin's power = 100
Player Jenifer's power = 100
Ho Yin attacks Jenifer!
Jenifer wins
Round 2
Player Ho Yin's power = 99
Player Jenifer's power = 101
Ho Yin attacks Jenifer!
Ho Yin wins
...
You can download the file here:
Player.java: Player.java
FighterTest(main program): FighterTest.java

Or you may download the source code as a zip file:Lingnan Fighting

9月 29, 2007

Even or Odd


It is a very simple program for detect what kind of numbers you type. Is the number a odd or not?

The sample of the program:


You can download the file here:
EvenOROddTest: EvenOROddTest

Or you may dowonload the source code as a zip file:EvenOROddTest