コード例 #1
0
ファイル: Utility.cs プロジェクト: KeilCarpenter/Monopoly
 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);
 }
コード例 #2
0
        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());
        }
コード例 #3
0
        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());
        }
コード例 #4
0
        // 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);
            }
        }
コード例 #5
0
        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);
            }
        }
コード例 #6
0
        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());
        }
コード例 #7
0
        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());
        }
コード例 #8
0
ファイル: Utility.cs プロジェクト: jizhe7550/MonoPoly
 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));
     }
 }
コード例 #9
0
ファイル: Utility.cs プロジェクト: jizhe7550/MonoPoly
 public decimal getRent(ref Player player)
 {
     return(rentMultiplier * player.getLastMove());
 }
コード例 #10
0
ファイル: Utility.cs プロジェクト: KeilCarpenter/Monopoly
 public decimal getRent(ref Player player)
 {
     return (rentMultiplier * player.getLastMove());
 }
コード例 #11
0
        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();
        }