⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 player.java

📁 大富翁游戏monopoli
💻 JAVA
字号:
import java.io.*;import java.util.*;public class Player {  private int player;  private int position;  private int[] tosses;  private int sum;  private String filename;  private int[] estate;    // hidden attributes  private int toss;  private boolean blocked;  private static int _player = 0;  public Player(String fn, int go) throws TooManyPlayersException, IOException, FileNotFoundException {    toss = -1;     if (_player==4) throw new TooManyPlayersException();    player = ((++_player == 4)?5:_player); // i player sono numerati 1 2 3 5    filename = fn;    position = go;    sum = 3000;    blocked=false;    BufferedReader in = new BufferedReader(new FileReader(filename));    String line = in.readLine(); // contiene i lanci dei dadi mn1...nm    char[] chars = line.toCharArray();    tosses = new int[chars[0]-'0'];    for (int i = 1; i<chars.length; i++)       tosses[i-1] = chars[i]-'0';    line = in.readLine(); // contiene le proprietà m n1 n2 ..nm    StringTokenizer st = new StringTokenizer(line," ");    int n = new Integer(st.nextToken()).intValue();    estate = new int[n];    for (int i = 1; i<=n; i++)       estate[i-1] = new Integer(st.nextToken()).intValue();        in.close();  }  public int[] getEstate() {return estate;}   public int getSum() {return sum;}  public void setSum(int s) {sum=s;}  public int nextDiceToss(){    ++toss;    if (blocked) {      toggleCaptiveStatus();      return 0;    } else return tosses[toss];  }     public void move(int t) {position += t;}  public void setPosition(int i) {position = i;}  public int getPosition() {return position;}  public int id() {return player;}  public void toggleCaptiveStatus() {blocked = !blocked;}  public String toString() {return "The Player «"+player+"» is on lot «"+(position+1)+"»; it has «"+sum+"» Euro.";}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -