public String[] getPropertyName() {
   String[] save = new String[x.getProperties().size()];
   for (int i = 0; i < x.getProperties().size(); i++) {
     save[i] = (Game.SlotsList[x.getProperties().get(i)]).getName();
   }
   return save;
 }
  public void itemStateChanged(ItemEvent e) {
    if (e.getStateChange() == ItemEvent.SELECTED) {
      p5.add(mortgage);
      Slot pobject;
      pobject = Game.SlotsList[x.getProperties().get(propertydisplay.getSelectedIndex())];
      if (pobject instanceof Property) {
        ((Property) (pobject)).monopolizeProperty();
        pr1.setText("Buy Price:" + pobject.getBuyPrice());
        pr2.setText("Rent Price:" + pobject.getRentPrice());
        pr3.setText("House Price:" + pobject.getHousePrice());
        pr4.setText("Hotel Price:" + pobject.getHotelPrice());
        pr5.setText("Mortgaged:" + pobject.getMortgage());
      } else if (pobject instanceof Railroad) {
        pobject.adjustRentPrice();
        pr1.setText("Buy Price:" + pobject.getBuyPrice());
        pr2.setText("Rent Price:" + pobject.getRentPrice());
        pr3.setText("");
        pr4.setText("");
        pr5.setText("");

      } else {
        pobject.adjustDiceFactor();
        pr1.setText("Buy Price:" + pobject.getBuyPrice());
        pr2.setText("Dice Factor:" + pobject.getDiceFactor());
        pr3.setText("");
        pr4.setText("");
        pr5.setText("");
      }
    }
  }
  public static int displayProperties(Player player) {
    Property[] properties;
    properties = new Property[] {};

    properties = player.getProperties().toArray(properties);
    if (properties.length == 0) {
      return 0;
    }

    System.out.println("Properties you own:");
    for (int i = 0; i < properties.length; i++) {
      System.out.println(String.format("%s) %s\n", (i + 1), properties[i]));
    }

    return properties.length;
  }
  public static void sellProperty(Player player) {
    Property[] properties;
    Property property;
    int propertyCount, response, sellValue;
    String message;
    propertyCount = displayProperties(player);

    if (propertyCount == 0) {
      System.out.println("You don't own any properties");
      handlePlayerInput(player);
      return;
    }

    message =
        String.format(
            "Pick a number between 1 and %s " + "to sell the associated property", propertyCount);

    System.out.println(message);

    response = Util.getOptionNum(propertyCount);
    if (response == 0) {
      handlePlayerInput(player);
      return;
    }

    properties = new Property[] {};
    properties = player.getProperties().toArray(properties);

    property = properties[response - 1];

    sellValue = property.getSellValue();

    System.out.println(
        "Are you sure you want to sell " + property.getName() + " for " + sellValue + " bits? Y/N");

    if (Util.getResponse()) {
      property.sell();
      System.out.println(
          "*" + player.getName() + " sold " + property.getName() + " for " + sellValue + " bits*");
    } else {
      System.out.println("Transaction cancelled");
    }

    handlePlayerInput(player);
  }
  public static void listProperties(Player player) {
    Property[] properties;
    properties = new Property[] {};

    properties = player.getProperties().toArray(properties);

    if (properties.length == 0) {
      System.out.println("You don't own any properties");
      handlePlayerInput(player);
      return;
    }

    System.out.println("\nProperties you own:");
    for (Property property : properties) {
      System.out.println(property);
      board.getPropertyCard(property.getName()).display();
    }

    handlePlayerInput(player);
  }
  public static void buyStable(Player player) {
    Property[] properties;
    Property property;
    int propertyCount, response, stablePrice;
    String message;

    propertyCount = displayProperties(player);

    if (propertyCount == 0) {
      System.out.println("You don't own any properties");
      handlePlayerInput(player);
      return;
    }

    message =
        String.format(
            "Pick a number between 1 and %s "
                + "to buy stables for the associated property "
                + "or press Enter to cancel",
            propertyCount);

    System.out.println(message);

    response = Util.getOptionNum(propertyCount);
    if (response == 0) {
      handlePlayerInput(player);
      return;
    }

    properties = new Property[] {};
    properties = player.getProperties().toArray(properties);

    property = properties[response - 1];

    if (property.getNumStables() == Property.MAXSTABLES) {
      System.out.println(property.getName() + " already has the " + "maximum number of stables");
      handlePlayerInput(player);
      return;
    }

    if (property.getType() != PropertyType.NORMAL) {
      System.out.println(property.getName() + " can not " + "support stables");
      handlePlayerInput(player);
      return;
    }

    stablePrice = board.findPropertyIndex(property.getName()) / (Board.BOARDSPACES / 4) + 1;

    stablePrice *= 50;

    Property[] groupProperties;
    groupProperties = board.getGroupProperties(property);

    for (Property groupProperty : groupProperties) {
      if (!groupProperty.getOwner().equals(player)) {
        System.out.println(
            "You can not buy stables on this "
                + "property until you own every property in "
                + property.getGroup()
                + " group");
        handlePlayerInput(player);
        return;
      }
    }

    if (player.getCash() < stablePrice) {
      System.out.println("You cannot afford to place a stable " + "on this property");
      handlePlayerInput(player);
      return;
    }

    System.out.println(
        "Are you sure you want to put an additional "
            + "stable on "
            + property.getName()
            + " for "
            + stablePrice
            + " bits? Y/N");

    if (Util.getResponse()) {
      property.purchase(player);
      System.out.println(
          "*"
              + player.getName()
              + " purchased an "
              + "additional stable on "
              + property.getName()
              + "*");
    } else {
      System.out.println("Transaction cancelled");
    }

    handlePlayerInput(player);
  }
  public void actionPerformed(ActionEvent e) {
    String event = e.getActionCommand();
    moneyLabel.setText("Money Owned:" + x.getMoney() + "");
    jcards.setText("Get out of Jail Cards Owned: " + x.getJailCards());
    if (event.equals("mortgage")
        && (Game.SlotsList[x.getProperties().get(propertydisplay.getSelectedIndex())]
            instanceof Property)) {
      Slot pobject = Game.SlotsList[x.getProperties().get(propertydisplay.getSelectedIndex())];
      if (pobject.getMortgage()) {
        if (JOptionPane.showConfirmDialog(
                null,
                "Would you like to unmortgage your property for $" + pobject.getMortgageV() * 1.10,
                "Mortgage Choice",
                JOptionPane.YES_NO_OPTION)
            == JOptionPane.YES_OPTION) {
          pobject.endMortgage();
        } else {

        }
      } else {
        if (JOptionPane.showConfirmDialog(
                null,
                "Would you like to mortgage your property for $" + pobject.getMortgageV(),
                "Mortgage Choice",
                JOptionPane.YES_NO_OPTION)
            == JOptionPane.YES_OPTION) {
          pobject.mortgageProperty();
        } else {

        }
      }
      // WIP Code!
    } else if (event.equals("buyHouse")) {
      HouseMenu one =
          new HouseMenu(
              x,
              "buy"); // pass along the player and what sort of thing the player wants to be doing
      one.setVisible(true);
      do {
        try {
          TimeUnit.SECONDS.sleep(1);
        } catch (InterruptedException a) {
          // nothing
        }
      } while (one.done == false);
      one.dispose();
    } else if (event.equals("sellHouse")) {
      HouseMenu one = new HouseMenu(x, "sell");
      one.setVisible(true);
      do {
        try {
          TimeUnit.SECONDS.sleep(1);
        } catch (InterruptedException a) {
          // nothing
        }
      } while (one.done == false);
      one.dispose();
    } else {
      Property choice =
          (Property) (Game.SlotsList[x.getProperties().get(propertydisplay.getSelectedIndex())]);
      int res =
          JOptionPane.showConfirmDialog(
              null,
              "Are you sure you want to sell this property, along with any houses and hotels?",
              "Confirm your choice",
              JOptionPane.YES_NO_OPTION);
      if (res == JOptionPane.YES_OPTION) {
        choice.sellProperty();
      } else {
        // nothing
      }
    }
  }