public void purchase(Owner landed, Property unownedSpace) { int origMoney = landed.money; if (landed.money >= unownedSpace.value) { landed.money = landed.money - unownedSpace.value; unownedSpace.setOwned (landed); landed.properties.Add (unownedSpace); Console.WriteLine ("Player " + landed.ID + " pays $" + unownedSpace.value + " from $" + origMoney + " to purchase " + unownedSpace.title); Console.WriteLine ("They now have $" + landed.money); } else { Console.WriteLine ("Not enough money to buy " + unownedSpace.title + "!"); } }
public void payRent(Owner landed, Property ownedSpace) //pay rent from piece to space owner { int rentOwed = 0; if (ownedSpace.title == "Electric Company") { bool ownsWW = false; foreach(Property p in ownedSpace.player.properties) { if(p.title == "Water Works") { ownsWW = true; } } if(ownsWW) { rentOwed = (10 * this.diceTotal); } } else if (ownedSpace.title == "Water Works") { bool ownsEC = false; foreach(Property p in ownedSpace.player.properties) { if(p.title == "Electric Company") { ownsEC = true; } } if(ownsEC) { rentOwed = (10 * this.diceTotal); } } else { rentOwed = ownedSpace.rents [ownedSpace.buildings]; } landed.money = landed.money - rentOwed; ownedSpace.player.money = ownedSpace.player.money + rentOwed; Console.WriteLine("Player " + landed.ID + " pays Player " + ownedSpace.player.ID + " $" + rentOwed + " and now has $" + landed.money + ". Player " + ownedSpace.player.ID + " now has $" + ownedSpace.player.money); if(landed.money < 0) { Console.WriteLine("Player " + landed.ID + " loses the game"); gameOver = true; } }
public Property(string in_title, int in_value, int[] in_rents, int in_mortgage, string in_colorGroup) { mortgage = in_mortgage; value = in_value; isMortgaged = false; buildings = 0; rents = in_rents; colorGroup = in_colorGroup; player = null; //not yet owned Console.WriteLine ("property created"); title = in_title; }
public void setOwned(Owner cplayer) { player = cplayer; }
public Piece(string in_type, string color, int id) { player = new Owner (color, id); type = in_type; doubcount = 0; isJailed = false; location = 0; Console.WriteLine (type + " created"); }