java - 为什么我在intellij-idea中运行代码但在eclipse上运行时扫描仪不接受输入

标签 java intellij-idea

所以我遇到了这个问题,当我在 IntelliJ IDEA Community Edition 16.3.2 中创建扫描仪时,它只是陷入等待用户输入的状态。我按 Enter 或尝试输入任何内容,但它不接受它,当我在 Eclipse 中运行相同的代码时,它运行没有任何问题。那么这是一个问题吗?我查看了错误报告,发现版本 9 和 10 中存在类似的错误,但它仍然存在吗?

这是我尝试运行的代码:

测试用例类:

public class GameLogicTest extends TestCase {
public void testBuyHouse() throws Exception {
    Player player = new Player(1000,0);
    GameboardSquare property = new GameboardSquare("Seb", 100,50,50,100,150,200,250,300,200,0,3,0,player,false);
    GameboardSquare[] gameboard = new GameboardSquare[1];
    gameboard[0] = property;
    GameLogic game = new GameLogic(gameboard);
    Board board = new Board(gameboard);
    board.setMonopolyBoard(gameboard);
    game.buyHouse(player,0);
}}

我尝试运行/调试的代码:

public class GameLogic extends Board {
Scanner input = new Scanner(System.in);

public GameLogic(GameboardSquare[] monopolyBoard) {
    super(monopolyBoard);
}
public boolean buyHouse(Player player, int propertyIndex) {
  boolean boughtHouse = false;
  GameboardSquare property = getMonopolyBoard()[propertyIndex];
  if (property.getNumberHouse() <= 3) {
      System.out.println("How many houses you want to buy? it must be between 1-4: ");
      int numHouseToBuy = input.nextInt();
      System.out.println(numHouseToBuy);
      while (numHouseToBuy > 4) {
          System.out.println("To much to buy only 1-4");
          System.out.println("How many houses you want to buy? it must be between 1-4");
          numHouseToBuy = input.nextInt();
      }
      //think over the logic of the this switch statement
      switch (numHouseToBuy) {
          case 1:
              if (numHouseToBuy + property.getNumberHouse() <= 4) {
                  player.setcurrentMoney(player.getcurrentMoney() - property.getHouseCost());
                  property.setNumberHouse(property.getNumberHouse() + numHouseToBuy);
                  boughtHouse = true;
              } else {
                  //need to copy this to the other switch
                  System.out.println("To many houses on this property");
                  System.out.println("You can only buy " + (4 - property.getNumberHouse()) );
                  numHouseToBuy = input.nextInt();
                  while (numHouseToBuy + property.getNumberHouse() > 4) {
                      System.out.println("To many houses on this property");
                      numHouseToBuy = toManyHouseOnPropertyError();
                  }
                  player.setcurrentMoney(player.getcurrentMoney() - property.getHouseCost());
                  property.setNumberHouse(property.getNumberHouse() + numHouseToBuy);
                  boughtHouse = true;
              }
              break;
          case 2:
              if (numHouseToBuy + property.getNumberHouse() <= 4) {
                  player.setcurrentMoney(player.getcurrentMoney() - (property.getHouseCost() * 2));
                  property.setNumberHouse(property.getNumberHouse() + numHouseToBuy);
                  boughtHouse = true;
              } else {
                  System.out.println("To many houses on this property");
                  numHouseToBuy = toManyHouseOnPropertyError();
                  while (numHouseToBuy + property.getNumberHouse() > 4) {
                      System.out.println("To many houses on this property");
                      numHouseToBuy = toManyHouseOnPropertyError();
                  }
                  player.setcurrentMoney(player.getcurrentMoney() - property.getHouseCost());
                  property.setNumberHouse(property.getNumberHouse() + numHouseToBuy);
                  boughtHouse = true;
              }
              break;
          case 3:
              if (numHouseToBuy + property.getNumberHouse() <= 4) {
                  player.setcurrentMoney(player.getcurrentMoney() - (property.getHouseCost() * 3));
                  property.setNumberHouse(property.getNumberHouse() + numHouseToBuy);
                  boughtHouse = true;
              } else {
                  System.out.println("To many houses on this property");
                  numHouseToBuy = toManyHouseOnPropertyError();
                  while (numHouseToBuy + property.getNumberHouse() > 4) {
                      System.out.println("To many houses on this property");
                      numHouseToBuy = toManyHouseOnPropertyError();
                  }
                  player.setcurrentMoney(player.getcurrentMoney() - property.getHouseCost());
                  property.setNumberHouse(property.getNumberHouse() + numHouseToBuy);
                  boughtHouse = true;
              }
              break;
          case 4:
              if (numHouseToBuy + property.getNumberHouse() <= 4) {
                  player.setcurrentMoney(player.getcurrentMoney() - (property.getHouseCost() * 4));
                  property.setNumberHouse(property.getNumberHouse() + numHouseToBuy);
                  boughtHouse = true;
              } else {
                  System.out.println("To many houses on this property");
                  System.out.println("You can only buy " + (4 - property.getNumberHouse()) );
                  numHouseToBuy = input.nextInt();
                  while (numHouseToBuy + property.getNumberHouse() > 4) {
                      System.out.println("To many houses on this property");
                      numHouseToBuy = toManyHouseOnPropertyError();
                  }
                  player.setcurrentMoney(player.getcurrentMoney() - property.getHouseCost());
                  property.setNumberHouse(property.getNumberHouse() + numHouseToBuy);
                  boughtHouse = true;
              }
              break;
          default:
              break;
      }
      return boughtHouse;
  } else {
      System.out.println("You own 4 houses on this property already");
      return boughtHouse;
  }}}

我的其他类(class):

public class Board {
private GameboardSquare[] monopolyBoard;
private Player player1;
private Player player2;
public Board(GameboardSquare[] monopolyBoard) {
    this.monopolyBoard = monopolyBoard;
}
//    public Board(){
////        monopolyBoard = new GameboardSquare[40];
//    }

public void setupGameBoard(File propertySquares) throws Exception{
    Scanner input1 = new Scanner(System.in);
    GameboardSquare a;
    while (input1.hasNextLine()){
        int index = 0;
        String property = input1.nextLine();
        String[] propertySqaure = property.split(",");
        // TODO: 11/15/2016 add other sqaure file some how
        switch (index){
            case 0:
                a = new GameboardSquare("Go",0,0,0,0,0,0,0,0,0,200,0,0,null,false);
                monopolyBoard[index++] = a;
                break;
            case 2:
                //community chest
                a = new GameboardSquare("Community Chest",0,0,0,0,0,0,0,0,0,0,0,0,null,false);
                monopolyBoard[index++] = a;
                break;
            case 4:
                //income tax
                break;
            case 7:
                //chance
                a = new GameboardSquare("Chance",0,0,0,0,0,0,0,0,0,0,0,0,null,false);
                monopolyBoard[index++] = a;
                break;
            case 10:
                //visit jail
                a = new GameboardSquare("Just Visiting Jail",0,0,0,0,0,0,0,0,0,0,0,0,null,false);
                monopolyBoard[index++] = a;
                break;
            case 17:
                //community chest
                a = new GameboardSquare("Community Chest",0,0,0,0,0,0,0,0,0,0,0,0,null,false);
                monopolyBoard[index++] = a;
                break;
            case 20:
                //free parking
                a = new GameboardSquare("Free Parking",0,0,0,0,0,0,0,0,0,0,0,0,null,false);
                monopolyBoard[index++] = a;
                break;
            case 22:
                //chance
                a = new GameboardSquare("Chance",0,0,0,0,0,0,0,0,0,0,0,0,null,false);
                monopolyBoard[index++] = a;
                break;
            case 40:
                //go to jail
                a = new GameboardSquare("Go To Jail",0,0,0,0,0,0,0,0,0,0,0,0,null,false);
                monopolyBoard[index++] = a;
                break;
            case 43:
                //community chest
                a = new GameboardSquare("Community Chest",0,0,0,0,0,0,0,0,0,0,0,0,null,false);
                monopolyBoard[index++] = a;
                break;
            case 46:
                ///chance
                a = new GameboardSquare("Chance",0,0,0,0,0,0,0,0,0,0,0,0,null,false);
                monopolyBoard[index++] = a;
                break;
            case 48:
                //luxury tax
                break;
            default:
                a = parseMethod(propertySqaure);
                monopolyBoard[index++] = a;
                break;
        }
    }
}

public GameboardSquare parseMethod(String[] propertySqaure) {
    String propertyName = propertySqaure[0];
    int value = Integer.parseInt(propertySqaure[1]);
    int rent = Integer.parseInt(propertySqaure[3]);
    int rent1 = Integer.parseInt(propertySqaure[4]);
    int rent2 = Integer.parseInt(propertySqaure[5]);
    int rent3 = Integer.parseInt(propertySqaure[6]);
    int rent4 = Integer.parseInt(propertySqaure[7]);
    int hotel = Integer.parseInt(propertySqaure[8]);
    int mortgage = Integer.parseInt(propertySqaure[9]);
    int houseCost = Integer.parseInt(propertySqaure[2]);
//        int hotelCost = Integer.parseInt(propertySqaure[2]);
    int moneyGive = Integer.parseInt(propertySqaure[10]);
    Player owner = null;
    GameboardSquare a = new             GameboardSquare(propertyName,value,houseCost,rent,rent1,rent2,rent3,rent4,hotel,    mortgage, moneyGive,0,0,owner, false);
    return a;
}

public GameboardSquare[] getMonopolyBoard() {
    return monopolyBoard;
}

public Player getPlayer1() {
    return player1;
}

public void setPlayer1(Player player) {
    this.player1 = player;
}

public Player getPlayer2() {
    return player2;
}

public void setPlayer2(Player player2) {
    this.player2 = player2;
}

public void setMonopolyBoard(GameboardSquare[] monopolyBoard) {
    this.monopolyBoard = monopolyBoard;
}}

玩家:

public class Player {
private int currentMoney;
private int moveIndex;

public Player(int currentMoney, int moveIndex) {
    this.moveIndex = moveIndex;
    this.currentMoney = currentMoney;
}


public void moves(Player player, int moves) {
    int a = player.getMoveIndex() + moves;
    if (a > 41) {
        int b = a - 40;
        player.setMoveIndex(b);
        if (player.getMoveIndex() != 0) {
            player.setcurrentMoney(player.getcurrentMoney() + 200);
        }
    } else {
        player.setMoveIndex(a);
    }
}

public void rollsDie(Dice die1, Dice die2) {
    int max = 6;
    int min = 1;
    //rolls the diecs and set the die resules
    //returnes the dies reslues //idk
    Random rand = new Random();
    int value = rand.nextInt(50);
//        This will give value from 0 to 49.
//        For 1 to 50: 
    die1.setDie(rand.nextInt((max - min) + 1) + min);
    die2.setDie(rand.nextInt((max - min) + 1) + min);
}

public int getcurrentMoney() {
    return currentMoney;
}

public void setcurrentMoney(int currentMoney) {
    this.currentMoney = currentMoney;
}

public int getMoveIndex() {
    return moveIndex;
}

public void setMoveIndex(int moveIndex) {
    this.moveIndex = moveIndex;
}}

游戏广场:

public class GameboardSquare {
private String squareName;
private int cost;
private int hotel;
private int rent;
private int moneyGive;
private int rent1;
private int rent2;
private int rent3;
private int rent4;
private int mortgage;
private int houseCost;
private int hotelCost;
private int numberHouse;
private int numberHotels;
private boolean hasMortgage;
private Player propertyOwner;

//todo add player owns var and player mortgage var
public GameboardSquare(String squareName, int cost, int houseCost, int rent, int rent1, int rent2, int rent3,
                       int rent4, int hotel, int mortgage, int moneyGive, int numberHouse, int numberHotels, Player owner, boolean hasMortgage) {
    this.squareName = squareName;
    this.cost = cost;
    this.hotel = hotel;
    this.rent = rent;
    this.moneyGive = moneyGive;
    this.rent1 = rent1;
    this.rent2 = rent2;
    this.rent3 = rent3;
    this.rent4 = rent4;
    this.mortgage = mortgage;
    this.houseCost = houseCost;
    this.numberHouse = numberHouse;
    this.numberHotels = numberHotels;
    this.hasMortgage = hasMortgage;
    this.propertyOwner = owner;//// TODO: 11/15/2016 make a more specific
}

public boolean hasHouse(Player player, GameboardSquare[] monopolyBoard) {
    return monopolyBoard[player.getMoveIndex()].getNumberHouse() > 0;
}

public boolean hasHotel(Player player, GameboardSquare[] monopolyBoard) {
    return monopolyBoard[player.getMoveIndex()].getNumberHotels() > 0;
}

public String getSquareName() {
    return squareName;
}

public void setSquareName(String squareName) {
    this.squareName = squareName;
}

public int getCost() {
    return cost;
}

public void setCost(int cost) {
    this.cost = cost;
}

public int getHotel() {
    return hotel;
}

public void setHotel(int hotel) {
    this.hotel = hotel;
}

public int getRent() {
    return rent;
}

public void setRent(int rent) {
    this.rent = rent;
}

public int getMoneyGive() {
    return moneyGive;
}

public void setMoneyGive(int moneyGive) {
    this.moneyGive = moneyGive;
}

public int getRent1() {
    return rent1;
}

public void setRent1(int rent1) {
    this.rent1 = rent1;
}

public int getRent2() {
    return rent2;
}

public void setRent2(int rent2) {
    this.rent2 = rent2;
}

public int getRent3() {
    return rent3;
}

public void setRent3(int rent3) {
    this.rent3 = rent3;
}

public int getRent4() {
    return rent4;
}

public void setRent4(int rent4) {
    this.rent4 = rent4;
}

public int getMortgage() {
    return mortgage;
}

public void setMortgage(int mortgage) {
    this.mortgage = mortgage;
}

public int getHouseCost() {
    return houseCost;
}

public void setHouseCost(int houseCost) {
    this.houseCost = houseCost;
}

public int getHotelCost() {
    return hotelCost;
}

public void setHotelCost(int hotelCost) {
    this.hotelCost = hotelCost;
}

public int getNumberHouse() {
    return numberHouse;
}

public void setNumberHouse(int numberHouse) {
    this.numberHouse = numberHouse;
}

public int getNumberHotels() {
    return numberHotels;
}

public void setNumberHotels(int numberHotels) {
    this.numberHotels = numberHotels;
}

public boolean isHasMortgage() {
    return hasMortgage;
}

public void setHasMortgage(boolean hasMortgage) {
    this.hasMortgage = hasMortgage;
}

public Player getPropertyOwner() {
    return propertyOwner;
}

public void setPropertyOwner(Player propertyOwner) {
    this.propertyOwner = propertyOwner;
}}

一些屏幕截图 智能: intellij picture

eclipse:进入前输入:eclipse picture

最佳答案

我用 IntelliJ Ultimate Edition 尝试过,可以买 1 栋房子。

How many houses you want to buy? it must be between 1-4: 
1
1
boughtHouse

下面的代码有一些小改动。

import java.io.File;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        new Main().testBuyHouse();
    }

    public void testBuyHouse() {
        Player player = new Player(1000000, 0);
        GameboardSquare property = new GameboardSquare("Seb", 100, 50, 50, 100, 150, 200, 250, 300, 200, 0, 3, 0, player, false);
        GameboardSquare[] gameboard = new GameboardSquare[3];
        gameboard[0] = property;
        GameLogic game = new GameLogic(gameboard);
        Board board = new Board(gameboard);
        board.setMonopolyBoard(gameboard);
        game.buyHouse(player, 0);
    }
}

class GameLogic extends Board {
    Scanner input = new Scanner(System.in);

    public GameLogic(GameboardSquare[] monopolyBoard) {
        super(monopolyBoard);
    }

    public boolean buyHouse(Player player, int propertyIndex) {
        boolean boughtHouse = false;
        GameboardSquare property = getMonopolyBoard()[propertyIndex];
        if (property.getNumberHouse() <= 3) {
            System.out.println("How many houses you want to buy? it must be between 1-4: ");
            int numHouseToBuy = input.nextInt();
            System.out.println(numHouseToBuy);
            while (numHouseToBuy > 4) {
                System.out.println("To much to buy only 1-4");
                System.out.println("How many houses you want to buy? it must be between 1-4");
                numHouseToBuy = input.nextInt();
            }
            //think over the logic of the this switch statement
            switch (numHouseToBuy) {
                case 1:
                    if (numHouseToBuy + property.getNumberHouse() <= 4) {
                        player.setcurrentMoney(player.getcurrentMoney() - property.getHouseCost());
                        property.setNumberHouse(property.getNumberHouse() + numHouseToBuy);
                        boughtHouse = true;
                        System.out.println("boughtHouse");
                    } else {
                        //need to copy this to the other switch
                        System.out.println("To many houses on this property");
                        System.out.println("You can only buy " + (4 - property.getNumberHouse()));
                        numHouseToBuy = input.nextInt();
                        while (numHouseToBuy + property.getNumberHouse() > 4) {
                            System.out.println("To many houses on this property");
                            numHouseToBuy = 4;
                        }
                        player.setcurrentMoney(player.getcurrentMoney() - property.getHouseCost());
                        property.setNumberHouse(property.getNumberHouse() + numHouseToBuy);
                        boughtHouse = true;
                    }
                    break;
                case 2:
                    if (numHouseToBuy + property.getNumberHouse() <= 4) {
                        player.setcurrentMoney(player.getcurrentMoney() - (property.getHouseCost() * 2));
                        property.setNumberHouse(property.getNumberHouse() + numHouseToBuy);
                        boughtHouse = true;
                    } else {
                        System.out.println("To many houses on this property");
                        numHouseToBuy = 4;
                        while (numHouseToBuy + property.getNumberHouse() > 4) {
                            System.out.println("To many houses on this property");
                            numHouseToBuy = 4;
                        }
                        player.setcurrentMoney(player.getcurrentMoney() - property.getHouseCost());
                        property.setNumberHouse(property.getNumberHouse() + numHouseToBuy);
                        boughtHouse = true;
                    }
                    break;
                case 3:
                    if (numHouseToBuy + property.getNumberHouse() <= 4) {
                        player.setcurrentMoney(player.getcurrentMoney() - (property.getHouseCost() * 3));
                        property.setNumberHouse(property.getNumberHouse() + numHouseToBuy);
                        boughtHouse = true;
                    } else {
                        System.out.println("To many houses on this property");
                        numHouseToBuy = 4;
                        while (numHouseToBuy + property.getNumberHouse() > 4) {
                            System.out.println("To many houses on this property");
                            numHouseToBuy = 4;
                        }
                        player.setcurrentMoney(player.getcurrentMoney() - property.getHouseCost());
                        property.setNumberHouse(property.getNumberHouse() + numHouseToBuy);
                        boughtHouse = true;
                    }
                    break;
                case 4:
                    if (numHouseToBuy + property.getNumberHouse() <= 4) {
                        player.setcurrentMoney(player.getcurrentMoney() - (property.getHouseCost() * 4));
                        property.setNumberHouse(property.getNumberHouse() + numHouseToBuy);
                        boughtHouse = true;
                    } else {
                        System.out.println("To many houses on this property");
                        System.out.println("You can only buy " + (4 - property.getNumberHouse()));
                        numHouseToBuy = input.nextInt();
                        while (numHouseToBuy + property.getNumberHouse() > 4) {
                            System.out.println("To many houses on this property");
                            numHouseToBuy = 4;
                        }
                        player.setcurrentMoney(player.getcurrentMoney() - property.getHouseCost());
                        property.setNumberHouse(property.getNumberHouse() + numHouseToBuy);
                        boughtHouse = true;
                    }
                    break;
                default:
                    break;
            }
            return boughtHouse;
        } else {
            System.out.println("You own 4 houses on this property already");
            return boughtHouse;
        }
    }
}

class Board {
    private GameboardSquare[] monopolyBoard;
    private Player player1;
    private Player player2;

    Board(GameboardSquare[] monopolyBoard) {
        this.monopolyBoard = monopolyBoard;
    }
//    public Board(){
////        monopolyBoard = new GameboardSquare[40];
//    }

    public void setupGameBoard(File propertySquares) throws Exception {
        Scanner input1 = new Scanner(System.in);
        GameboardSquare a;
        while (input1.hasNextLine()) {
            int index = 0;
            String property = input1.nextLine();
            String[] propertySqaure = property.split(",");
            // TODO: 11/15/2016 add other sqaure file some how
            switch (index) {
                case 0:
                    a = new GameboardSquare("Go", 0, 0, 0, 0, 0, 0, 0, 0, 0, 200, 0, 0, null, false);
                    monopolyBoard[index++] = a;
                    break;
                case 2:
                    //community chest
                    a = new GameboardSquare("Community Chest", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, null, false);
                    monopolyBoard[index++] = a;
                    break;
                case 4:
                    //income tax
                    break;
                case 7:
                    //chance
                    a = new GameboardSquare("Chance", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, null, false);
                    monopolyBoard[index++] = a;
                    break;
                case 10:
                    //visit jail
                    a = new GameboardSquare("Just Visiting Jail", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, null, false);
                    monopolyBoard[index++] = a;
                    break;
                case 17:
                    //community chest
                    a = new GameboardSquare("Community Chest", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, null, false);
                    monopolyBoard[index++] = a;
                    break;
                case 20:
                    //free parking
                    a = new GameboardSquare("Free Parking", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, null, false);
                    monopolyBoard[index++] = a;
                    break;
                case 22:
                    //chance
                    a = new GameboardSquare("Chance", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, null, false);
                    monopolyBoard[index++] = a;
                    break;
                case 40:
                    //go to jail
                    a = new GameboardSquare("Go To Jail", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, null, false);
                    monopolyBoard[index++] = a;
                    break;
                case 43:
                    //community chest
                    a = new GameboardSquare("Community Chest", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, null, false);
                    monopolyBoard[index++] = a;
                    break;
                case 46:
                    ///chance
                    a = new GameboardSquare("Chance", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, null, false);
                    monopolyBoard[index++] = a;
                    break;
                case 48:
                    //luxury tax
                    break;
                default:
                    a = parseMethod(propertySqaure);
                    monopolyBoard[index++] = a;
                    break;
            }
        }
    }

    GameboardSquare parseMethod(String[] propertySqaure) {
        String propertyName = propertySqaure[0];
        int value = Integer.parseInt(propertySqaure[1]);
        int rent = Integer.parseInt(propertySqaure[3]);
        int rent1 = Integer.parseInt(propertySqaure[4]);
        int rent2 = Integer.parseInt(propertySqaure[5]);
        int rent3 = Integer.parseInt(propertySqaure[6]);
        int rent4 = Integer.parseInt(propertySqaure[7]);
        int hotel = Integer.parseInt(propertySqaure[8]);
        int mortgage = Integer.parseInt(propertySqaure[9]);
        int houseCost = Integer.parseInt(propertySqaure[2]);
//        int hotelCost = Integer.parseInt(propertySqaure[2]);
        int moneyGive = Integer.parseInt(propertySqaure[10]);
        Player owner = null;
        GameboardSquare a = new GameboardSquare(propertyName, value, houseCost, rent, rent1, rent2, rent3, rent4, hotel, mortgage, moneyGive, 0, 0, owner, false);
        return a;
    }

    GameboardSquare[] getMonopolyBoard() {
        return monopolyBoard;
    }

    public Player getPlayer1() {
        return player1;
    }

    public void setPlayer1(Player player) {
        this.player1 = player;
    }

    public Player getPlayer2() {
        return player2;
    }

    public void setPlayer2(Player player2) {
        this.player2 = player2;
    }

    public void setMonopolyBoard(GameboardSquare[] monopolyBoard) {
        this.monopolyBoard = monopolyBoard;
    }
}


class Player {
    private int currentMoney;
    private int moveIndex;

    public Player(int currentMoney, int moveIndex) {
        this.moveIndex = moveIndex;
        this.currentMoney = currentMoney;
    }


    public void moves(Player player, int moves) {
        int a = player.getMoveIndex() + moves;
        if (a > 41) {
            int b = a - 40;
            player.setMoveIndex(b);
            if (player.getMoveIndex() != 0) {
                player.setcurrentMoney(player.getcurrentMoney() + 200);
            }
        } else {
            player.setMoveIndex(a);
        }
    }


    public int getcurrentMoney() {
        return currentMoney;
    }

    public void setcurrentMoney(int currentMoney) {
        this.currentMoney = currentMoney;
    }

    public int getMoveIndex() {
        return moveIndex;
    }

    public void setMoveIndex(int moveIndex) {
        this.moveIndex = moveIndex;
    }
}

class GameboardSquare {
    private String squareName;
    private int cost;
    private int hotel;
    private int rent;
    private int moneyGive;
    private int rent1;
    private int rent2;
    private int rent3;
    private int rent4;
    private int mortgage;
    private int houseCost;
    private int hotelCost;
    private int numberHouse;
    private int numberHotels;
    private boolean hasMortgage;
    private Player propertyOwner;

    //todo add player owns var and player mortgage var
    GameboardSquare(String squareName, int cost, int houseCost, int rent, int rent1, int rent2, int rent3,
                    int rent4, int hotel, int mortgage, int moneyGive, int numberHouse, int numberHotels, Player owner, boolean hasMortgage) {
        this.squareName = squareName;
        this.cost = cost;
        this.hotel = hotel;
        this.rent = rent;
        this.moneyGive = moneyGive;
        this.rent1 = rent1;
        this.rent2 = rent2;
        this.rent3 = rent3;
        this.rent4 = rent4;
        this.mortgage = mortgage;
        this.houseCost = houseCost;
        this.numberHouse = numberHouse;
        this.numberHotels = numberHotels;
        this.hasMortgage = hasMortgage;
        this.propertyOwner = owner;//// TODO: 11/15/2016 make a more specific
    }

    public boolean hasHouse(Player player, GameboardSquare[] monopolyBoard) {
        return monopolyBoard[player.getMoveIndex()].getNumberHouse() > 0;
    }

    public boolean hasHotel(Player player, GameboardSquare[] monopolyBoard) {
        return monopolyBoard[player.getMoveIndex()].getNumberHotels() > 0;
    }

    public String getSquareName() {
        return squareName;
    }

    public void setSquareName(String squareName) {
        this.squareName = squareName;
    }

    public int getCost() {
        return cost;
    }

    public void setCost(int cost) {
        this.cost = cost;
    }

    public int getHotel() {
        return hotel;
    }

    public void setHotel(int hotel) {
        this.hotel = hotel;
    }

    public int getRent() {
        return rent;
    }

    public void setRent(int rent) {
        this.rent = rent;
    }

    public int getMoneyGive() {
        return moneyGive;
    }

    public void setMoneyGive(int moneyGive) {
        this.moneyGive = moneyGive;
    }

    public int getRent1() {
        return rent1;
    }

    public void setRent1(int rent1) {
        this.rent1 = rent1;
    }

    public int getRent2() {
        return rent2;
    }

    public void setRent2(int rent2) {
        this.rent2 = rent2;
    }

    public int getRent3() {
        return rent3;
    }

    public void setRent3(int rent3) {
        this.rent3 = rent3;
    }

    public int getRent4() {
        return rent4;
    }

    public void setRent4(int rent4) {
        this.rent4 = rent4;
    }

    public int getMortgage() {
        return mortgage;
    }

    public void setMortgage(int mortgage) {
        this.mortgage = mortgage;
    }

    public int getHouseCost() {
        return houseCost;
    }

    public void setHouseCost(int houseCost) {
        this.houseCost = houseCost;
    }

    public int getHotelCost() {
        return hotelCost;
    }

    public void setHotelCost(int hotelCost) {
        this.hotelCost = hotelCost;
    }

    public int getNumberHouse() {
        return numberHouse;
    }

    public void setNumberHouse(int numberHouse) {
        this.numberHouse = numberHouse;
    }

    public int getNumberHotels() {
        return numberHotels;
    }

    public void setNumberHotels(int numberHotels) {
        this.numberHotels = numberHotels;
    }

    public boolean isHasMortgage() {
        return hasMortgage;
    }

    public void setHasMortgage(boolean hasMortgage) {
        this.hasMortgage = hasMortgage;
    }

    public Player getPropertyOwner() {
        return propertyOwner;
    }

    public void setPropertyOwner(Player propertyOwner) {
        this.propertyOwner = propertyOwner;
    }
}

关于java - 为什么我在intellij-idea中运行代码但在eclipse上运行时扫描仪不接受输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41434108/

相关文章:

java - 使用 Java 从 xml 文件中提取值

java - SQL Server 存储过程的输出参数被截断为 4000 个字符

intellij-idea - IntelliJ IDEA 中的嬉皮士代码完成?

java - Intellij IDEA Tomcat git 克隆 Web 应用程序

java - PredictionIO:在 OSX 上为 postgresql 安装 JDBC 驱动程序

java - 在 java 中查询 xml 的最快方法

java - 从 arraylist 取消同步数组

eclipse - 编译过程中的不同 jar 版本 - Gradle 项目(IntelliJ 和 Eclipse 中)

android - 无法在 Intellij : "Warning: debug info can be unavailable." 中调试 android 应用程序

intellij-idea - IntelliJ IDEA : how to get notifications about changes in repository