Exemple #1
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);
                    }
                }
            }
        }