public override string landOn(ref Player player) { //Pay rent if needed if ((this.getOwner() != Banker.access()) && (this.getOwner() != player)) { //pay rent this.payRent(ref player); return string.Format("You rolled a total of {0}. So your rent is {0} x {1} = ${2}.", player.getLastMove(), Utility.rentMultiplier, (player.getLastMove() * Utility.rentMultiplier)); } else return base.landOn(ref player); }
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()); }
// 2.7 Extend use of Delegates and Events by adding at least two new Events to the game. private void playerdoubleDiceHandler(object sender, EventArgs e) { Player p = (Player)sender; if (p.getLastMove() == 12) { Console.WriteLine("Congratulations! You are a lucky dog! for Dice 12.But it is a long lane that has no turning."); this.makePlay(AgainPlayerIndex); } }
private void playerluckyDiceHanler(object sender, EventArgs e) { //2.7 Extend use of Delegates and Events by adding at least two new Events to the game. Player p = (Player)sender; if (p.getLastMove() == 6) { Console.WriteLine("Congratulations! You are a lucky dog! for Dice 6"); p.receive(66); } }
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()); }
public override string landOn(ref Player player) { //Pay rent if needed if ((this.getOwner() != Banker.access()) && (this.getOwner() != player)) { //pay rent this.payRent(ref player); return(string.Format("You rolled a total of {0}. So your rent is {0} x {1} = ${2}.", player.getLastMove(), Utility.rentMultiplier, (player.getLastMove() * Utility.rentMultiplier))); } else { return(base.landOn(ref player)); } }
public decimal getRent(ref Player player) { return(rentMultiplier * player.getLastMove()); }
public decimal getRent(ref Player player) { return (rentMultiplier * player.getLastMove()); }
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(); }