Example #1
0
        public override void LandedOn(Player curPlayer)
        {
            int tax;
            Debug.WriteLine("Player Landed on IncomeTax Cell");
            Console.WriteLine(curPlayer.Name + " arrived at " + this.CellName);

            //Minimum of 2000 and 10% of player's property value will be deducted.
            //Player should know his property value
               tax = (int)Math.Floor(Math.Min((double)2000, (double)(curPlayer.getNetWorth() * 0.1)));

            if (tax > 0)
            {
                Console.WriteLine("Sorry!!! $"+tax+" will be charged for tax");
                if (curPlayer.Money >= tax)
                {
                    curPlayer.Money -= tax;
                }
                else
                {
                    Console.WriteLine("You dont have suffecient funds \nPlease sell a property ");
                    if ((curPlayer.SellProperty() == true) &&   (curPlayer.Money < 0))
                    {
                        curPlayer.Money -= tax;
                    }
                    else
                    {
                        curPlayer.IsKickedOut = true;
                        Console.WriteLine("You dont have any propertie to sell \nYou have been kicked out of the game");
                    }
                }
            }
        }
Example #2
0
        public override void LandedOn(Player curPlayer)
        {
            const int FINE_FOR_JAIL=2000;

            Debug.WriteLine("Player Landed on GoToJail Cell");
            Console.WriteLine(curPlayer.Name + " arrived at " + this.CellName);
            Console.WriteLine("Sorry, $"+FINE_FOR_JAIL+" will be take for Fine");

            if (curPlayer.Money >= FINE_FOR_JAIL)
            {
               curPlayer.Money -= FINE_FOR_JAIL;
            }
            else
            {
                Console.WriteLine("You dont have suffecient funds \nPlease sell a property ");
                if ((curPlayer.SellProperty() == true) && (curPlayer.Money >= FINE_FOR_JAIL))
                {
                    curPlayer.Money -= FINE_FOR_JAIL;
                }
                else
                {
                    curPlayer.IsKickedOut = true;
                    Console.WriteLine("You dont have any propertie to sell \nYou have been kicked out of the game");
                }
            }
            moveToJailCell(curPlayer);
        }
Example #3
0
        public override void LandedOn(Player curPlayer)
        {
            string answer;
            Debug.WriteLine("Player Landed on PropertyCell Cell");
            Console.WriteLine(curPlayer.Name + " arrived at " + this.CellName);
            if (this.available)
            {
                Console.WriteLine("This cell is available");
                Console.Write("Do you want to buy this cell? (y/n): ");
                answer = Console.ReadLine();

                if (answer == "y" || answer == "Y")
                {
                    if (curPlayer.BuyProperty() == true)
                    {
                        Console.WriteLine("Congratulation , you own this cell now");
                    }
                    else
                    {
                        Console.WriteLine("You dont have suffecient money!!. Please sell a property ");
                        while (curPlayer.getPropertyNumber() > 0)
                        {
                            if ((curPlayer.SellProperty() == true) && (curPlayer.BuyProperty() == true))
                            {
                                Console.WriteLine("Congratulation , you own this cell now");
                                break;
                            }
                            else
                            {
                                Console.WriteLine("Sorry, due to shortage of money, it was not processed!");
                            }
                        }
                    }
                }

            }
            else if (this.owner != curPlayer)
            {
                Console.WriteLine("Unfortunaetly you are in someone's properties. You have to pay rent for him");
                if (curPlayer.PayRentTo() == true)
                {
                    Console.WriteLine("Rent fee $" + this.rentPrice + " have been paid to " + this.owner.Name);
                }
                else
                {
                    Console.WriteLine("You dont have suffecient funds!");
                    if ((curPlayer.SellProperty() == false) || (curPlayer.PayRentTo() == false))
                    {
                        curPlayer.IsKickedOut = true;
                        Console.WriteLine("You dont have any propertie to sell \nYou have been kicked out of the game");
                    }
                    else
                    {
                        Console.WriteLine("Rent fee $" + this.rentPrice + " have been paid to " + this.owner.Name);
                    }
                }
            }
        }