OptionList.java
上传用户:whhzxy
上传日期:2009-12-31
资源大小:269k
文件大小:2k
源码类别:

J2ME

开发平台:

Java

  1. import javax.microedition.lcdui.*;
  2. /**
  3.   * 选项菜单。
  4.   * @author SoftStar,嘟嘟熊
  5.   * @version 1.0
  6.   */
  7. public class OptionList
  8.     extends List
  9.     implements CommandListener {
  10.   /**
  11.    * richMan实例
  12.    */
  13.   private KMRichMan richMan;
  14.   /**
  15.    * playCanvas 实例
  16.    */
  17.   private PlayCanvas playCanvas;
  18.   /**
  19.    * 构造一个对象
  20.    * @param kmrichman richman实例
  21.    * @param playCanvas playCnavas实例
  22.    */
  23.   public OptionList(KMRichMan kmrichman,PlayCanvas playCanvas) {
  24.     super("选项菜单", 3);
  25.     this.richMan = kmrichman;
  26.     this.playCanvas = playCanvas;
  27.     append("资产状况", null);
  28.     append("股市行情", null);
  29.     append("返回游戏", null);
  30.     setCommandListener(this);
  31.   }
  32.   /**
  33.    * 处理按键
  34.    * @param command 不解释了
  35.    * @param displayalbe 不解释了
  36.    */
  37.   public void commandAction(Command command, Displayable displayable) {
  38.     switch (getSelectedIndex()) {
  39.       case 0:
  40.         int[] stock = new int[3];
  41.         // 计算股票价格
  42.         for (int i = 0; i < 3; i++) {
  43.           stock[i] = 0;
  44.           for (int j = 0; j < 4; j++) {
  45.             stock[i] += playCanvas.stock_price[j] * playCanvas.player_stock[i][j][0];
  46.           }
  47.         }
  48.         richMan.showPlayerStatus(playCanvas.player_money[0],
  49.                                  playCanvas.player_money[1],
  50.                                  playCanvas.player_money[2],
  51.                                  stock[0],
  52.                                  stock[1],
  53.                                  stock[2],
  54.                                  playCanvas.countPlayerGround(1),
  55.                                  playCanvas.countPlayerGround(10),
  56.                                  playCanvas.countPlayerGround(100),
  57.                                  playCanvas.countPlayerGround(2) + playCanvas.countPlayerGround(3),
  58.                                  playCanvas.countPlayerGround(20) + playCanvas.countPlayerGround(30),
  59.                                  playCanvas.countPlayerGround(200) + playCanvas.countPlayerGround(300),
  60.                                  playCanvas.countPlayerGround(4),
  61.                                  playCanvas.countPlayerGround(40),
  62.                                  playCanvas.countPlayerGround(400),
  63.                                  playCanvas.player_sequence);
  64.         break;
  65.       case 1:
  66.         richMan.setDisplayToStockList();
  67.         break;
  68.       case 2:
  69.         richMan.setDisplayToPlayCanvas1();
  70.         break;
  71.     }
  72.   }
  73. }