package edu.towson.cis.cosc603.project2.monopoly;

// TODO: Auto-generated Javadoc
/**
 * The Class PropertyCell.
 */
public class PropertyCell extends Cell {
	
	/** The color group. */
	private String colorGroup;
	
	/** The house price. */
	private int housePrice;
	
	/** The num houses. */
	private int numHouses;
	
	/** The rent. */
	private int rent;
	
	/** The sell price. */
	private int sellPrice;

	/**
	 * Gets the color group.
	 *
	 * @return the color group
	 */
	public String getColorGroup() {
		return colorGroup;
	}

	/**
	 * Gets the house price.
	 *
	 * @return the house price
	 */
	public int getHousePrice() {
		return housePrice;
	}

	/**
	 * Gets the num houses.
	 *
	 * @return the num houses
	 */
	public int getNumHouses() {
		return numHouses;
	}
    
    /* (non-Javadoc)
     * @see edu.towson.cis.cosc442.project1.monopoly.Cell#getPrice()
     */
    public int getPrice() {
		return sellPrice;
	}

	/**
	 * Gets the rent.
	 *
	 * @return the rent
	 */
	public int getRent() {
		int rentToCharge = rent;
		rentToCharge = calculateMonopoliesRent(rentToCharge);
		if(numHouses > 0) {
			rentToCharge = rent * (numHouses + 1);
		}
		return rentToCharge;
	}

	/**
	 * @param rentToCharge
	 * @return
	 */
	private int calculateMonopoliesRent(int rentToCharge) {
		String [] monopolies = theOwner.getMonopolies();
		for(int i = 0; i < monopolies.length; i++) {
			if(monopolies[i].equals(colorGroup)) {
				rentToCharge = rent * 2;
			}
		}
		return rentToCharge;
	}

	/* (non-Javadoc)
	 * @see edu.towson.cis.cosc442.project1.monopoly.Cell#playAction()
	 */
	public void playAction() {
		Player currentPlayer = null;
		if(!isAvailable()) {
			currentPlayer = GameMaster.instance().getCurrentPlayer();
			if(theOwner != currentPlayer) {
				currentPlayer.payRentTo(theOwner, getRent());
			}
		}
	}

	/**
	 * Sets the color group.
	 *
	 * @param colorGroup the new color group
	 */
	public void setColorGroup(String colorGroup) {
		this.colorGroup = colorGroup;
	}

	/**
	 * Sets the house price.
	 *
	 * @param housePrice the new house price
	 */
	public void setHousePrice(int housePrice) {
		this.housePrice = housePrice;
	}

	/**
	 * Sets the num houses.
	 *
	 * @param numHouses the new num houses
	 */
	public void setNumHouses(int numHouses) {
		this.numHouses = numHouses;
	}

	/**
	 * Sets the price.
	 *
	 * @param sellPrice the new price
	 */
	public void setPrice(int sellPrice) {
		this.sellPrice = sellPrice;
	}

	/**
	 * Sets the rent.
	 *
	 * @param rent the new rent
	 */
	public void setRent(int rent) {
		this.rent = rent;
	}
}

@@ -1030,262 +1030,8 @@
 nt;%0A
-%09%09rentToCharge = calculateMonopoliesRent(rentToCharge);%0A%09%09if(numHouses %3E 0) %7B%0A%09%09%09rentToCharge = rent * (numHouses + 1);%0A%09%09%7D%0A%09%09return rentToCharge;%0A%09%7D%0A%0A%09/**%0A%09 * @param rentToCharge%0A%09 * @return%0A%09 */%0A%09private int calculateMonopoliesRent(int rentToCharge) %7B%0A
 %09%09St
@@ -1077,16 +1077,16 @@
 lies();%0A
+
 %09%09for(in
@@ -1195,16 +1195,16 @@
 nt * 2;%0A
-
 %09%09%09%7D%0A%09%09%7D
@@ -1204,16 +1204,84 @@
 %09%09%7D%0A%09%09%7D%0A
+%09%09if(numHouses %3E 0) %7B%0A%09%09%09rentToCharge = rent * (numHouses + 1);%0A%09%09%7D%0A
 %09%09return

Revert "Created method calculateMonopoliesRent() in PropertyCell class"