毕业论文论文范文课程设计实践报告法律论文英语论文教学论文医学论文农学论文艺术论文行政论文管理论文计算机安全
您现在的位置: 毕业论文 >> 论文 >> 正文

连连看java程序 第8页

更新时间:2008-11-30:  来源:毕业论文

连连看java程序 第8页
package kyodai;

import java.io.*;
import java.net.*;
import java.util.*;

/**
 * 生成配置文件的类
 */

public class Setting {
 public final static int COLUMN = 17; //表格的列
 public final static int ROW = 10; //表格的行
 public final static int limitScore = 4; //每个方块限定的时间
 public final static int timeScore = 2; //时间奖励的分数
 public final static int wrongScore = 1; //选择失败扣分
 public final static int freshScore = 8; //刷新功能扣分
 public final static int hintScore = 10; //提示功能扣分
 public final static int bombScore = 12; //炸弹功能扣分
 public final static int correctScore = 10; //成功消除后加分
 public final static int MaxBlocks = 156; //最多可能出现的方块个数
 public final static int[] Level = {
  16, 22, 28, 34, 39}; //Level = N时需要的图标数

 public static int Music = 1, Sound = 1, LevelIndex = 2, Animate = 2;

 public Setting() {
 }

 /**
  * 从kyodai.ini文件中读取配置
 */
 public void load() {
  Properties pro;
  FileInputStream read = null;

  String Music = "1", Sound = "1", LevelIndex = "2", Animate = "2";

  try {
   read = new FileInputStream("kyodai.ini");
   pro = new Properties();
   pro.load(read);

   Music = pro.getProperty("Music");
   Sound = pro.getProperty("Sound");
   LevelIndex = pro.getProperty("LevelIndex");
   Animate = pro.getProperty("Animate");
   read.close();
  }
  catch (IOException ex) {
   Music = "1";
   Sound = "1";
   LevelIndex = "2";
   Animate = "2";
  }

  try {
   this.Music = Integer.parseInt(Music);
  }
  catch (NumberFormatException ex1) {
   this.Music = 1;
  }

  try {
   this.Sound = Integer.parseInt(Sound);
  }
  catch (NumberFormatException ex1) {
   this.Sound = 1;
  }


  try {
   this.LevelIndex = Integer.parseInt(LevelIndex);
  }
  catch (NumberFormatException ex1) {
   this.LevelIndex = 1;
  }
  this.LevelIndex = this.LevelIndex < 0 ? 0 : this.LevelIndex;
  this.LevelIndex = this.LevelIndex > 4 ? 4 : this.LevelIndex;

  try {
   this.Animate = Integer.parseInt(Animate);
  }
  catch (NumberFormatException ex1) {
   this.Animate = 1;
  }
  this.Animate = this.Animate < 1 ? 1 : this.Animate;
  this.Animate = this.Animate > 10 ? 10 : this.Animate;
 }

 /**
  * 将配置保存到kyodai.ini文件中
 */
 public void save() {
  Properties pro;
  FileOutputStream save = null;
  try {
   save = new FileOutputStream("kyodai.ini");
   pro = new Properties();
   pro.setProperty("Music", "" + Music);
   pro.setProperty("Sound", "" + Sound);
   pro.setProperty("LevelIndex", "" + LevelIndex);
   pro.setProperty("Animate", "" + Animate);
   pro.store(save, "Kyodai\r\n");
   save.close();
   System.out.println("Music=" + Music);
   System.out.println("Sound="+ Sound);
   System.out.println("LevelIndex="+ LevelIndex);
   System.out.println("Animate="+ Animate);

  }
  catch (IOException ex) {
  } }}

上一页  [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] 下一页

连连看java程序 第8页下载如图片无法显示或论文不完整,请联系qq752018766
设为首页 | 联系站长 | 友情链接 | 网站地图 |

copyright©youerw.com 优文论文网 严禁转载
如果本毕业论文网损害了您的利益或者侵犯了您的权利,请及时联系,我们一定会及时改正。