public void testLandOn() { Utility util = new Utility(); //Create two players Player p1 = new Player("Bill"); Player p2 = new Player("Fred", 1500); string msg; //test landon normally with no rent payable msg = util.landOn(ref p1); Console.WriteLine(msg); //set owner to p1 util.setOwner(ref p1); //move p2 so that utility rent can be calculated p2.move(); //p2 lands on util and should pay rent msg = util.landOn(ref p2); Console.WriteLine(msg); //check that correct rent has been paid decimal balance = 1500 - (6 * p2.getLastMove()); Assert.AreEqual(balance, p2.getBalance()); }
public void testPayRent() { Utility u = new Utility(); Player p = new Player("John", 1500); //move p so that utility rent can be calculated p.move(); u.payRent(ref p); //get p last move int i = p.getLastMove(); //check that p has played correct rent of 6 times last move decimal balance = 1500 - (6 * i); Assert.AreEqual(balance, p.getBalance()); }
/*----- METHOD TO MORTGAGE PROEPRTY -----*/ public void mortgageProperty(Player player) { decimal playerBalBeforeMortgage = player.getBalance(); string sPropPrompt = String.Format("{0}\tPlease select a property to mortgage:", this.playerPrompt(player)); //string sPlayerPrompt = String.Format("{0}\tPlease select a player to trade with:", this.playerPrompt(player)); //get selected property to mortgage TradeableProperty propertyToMortgage = (TradeableProperty)this.displayPropertyChooser(player.getPropertiesOwnedFromBoard(), sPropPrompt); //if dont own any properties if (player.getPropertiesOwnedFromBoard().Count == 0 /*propertyToMortgage == null*/) { //write message Console.WriteLine("\n{0}You do not own any properties to mortgage.", playerPrompt(player)); //return from method return; } decimal mortgageValue = propertyToMortgage.calculateMortgage(propertyToMortgage); Console.WriteLine("\tProperty you have chosen to mortgage is: " + propertyToMortgage.getName() + ", \tit's purchase price is $" + propertyToMortgage.getPrice()); Console.WriteLine("\n\tMortgage value is: " + mortgageValue); //check if property is already mortgaged if (propertyToMortgage.getMortgagedStatus() == false) { //make the bank pay the player mortgageValue Banker.access().pay(mortgageValue); //allocate mortgageValue to player player.receive(mortgageValue); Console.WriteLine("\n\tYour new balance is: " + player.getBalance()); propertyToMortgage.setPropertyIsMortgaged(); Console.WriteLine("\tyou've successfully mortaged " + propertyToMortgage.getName()); } else { Console.WriteLine("\n\t" + propertyToMortgage.getName() + " has already been mortgaged!"); } }
public void payJailFee(Player player) { //check player has money to pay if (player.getBalance() < 50) { Console.WriteLine("{0}Does not have enough money to get out of jail .", this.playerPrompt(player)); return; } //pay $50 to bank player.payJailFee(); Console.WriteLine("{0}Paid to get out of jail .", this.playerPrompt(player)); return; }
public void test_PlayerGettersAndSetters() { Banker theTestBanker = new Banker(); Player theTestPlayer = new Player(); //hasRolledDoubles bool theTestPlayer.get_hasRolledDoubles(); theTestPlayer.is_hasRolledDoubles(); theTestPlayer.hasRolledDoubles = true; theTestPlayer.not_hasRolledDoubles(); //paidFine bool theTestPlayer.getPaidFine(); theTestPlayer.isPaidFine(); theTestPlayer.notPaidFine(); //landedInJailByThreeStraightDoubles bool theTestPlayer.get_LandedInJailByThreeStraightDoubles(); theTestPlayer.not_LandedInJailByThreeStraightDoubles(); theTestPlayer.is_LandedInJailByThreeStraightDoubles(); //inJail bool theTestPlayer.getJailStats(); theTestPlayer.setIsInJail(); theTestPlayer.setNotInJail(); //lastMove int theTestPlayer.getLastMove(); theTestPlayer.getLocation(); theTestPlayer.getName(); theTestPlayer.getPropertiesOwned(); theTestPlayer.getBalance(); theTestPlayer.getBalance(); theTestPlayer.hasRolledDoublesInJail(); theTestPlayer.isNotActive(); theTestPlayer.get_firstTurnInJail(); theTestPlayer.not_firstTurnInJail(); }