示例#1
0
        public string getInformationSname(ListSpaces B)
        {
            Console.WriteLine("Enter the name of the space whom you want to have information: ");
            string n   = Console.ReadLine();
            int    pos = 0;

            while (!(B.onList(n, 40)))
            {
                Console.WriteLine("This propriety is not in the game board !");
                Console.WriteLine("Please write the space name correctly.");
                Console.WriteLine("If you want to leave, press 'z'");
                n = Console.ReadLine();
                if (n == "z")
                {
                    return(null);
                }
            }
            pos = B.getSpacePosition(n);
            return("This is the space n°" + pos + "\n" + B.getSpace(pos).ToString());
        }
示例#2
0
 public void buyHotel(ListSpaces B)
 {
     if (list_pr == null)
     {
         Console.WriteLine("You don't owe any propriety, you can't buy a hotel !");
     }
     else
     {
         Console.WriteLine("Enter the name of the street where you want to buy a hotel :");
         string prop_name = Console.ReadLine();
         while (!(B.onList(prop_name, 40)))
         {
             Console.WriteLine("This propriety is not in the game board !");
             Console.WriteLine("Please write the space name correctly.");
             Console.WriteLine("If you want to leave, press 'z'");
             prop_name = Console.ReadLine();
             if (prop_name == "z")
             {
                 break;
             }
         }
         if ((B.onList(prop_name, 40)))
         {
             while (!(list_pr.onList(prop_name, list_pr.Size)))
             {
                 Console.WriteLine("You don't possess this propriety !");
                 Console.WriteLine("Your proprieties are " + list_pr);
                 Console.WriteLine("Please write the propriety name correctly.");
                 Console.WriteLine("If you want to leave, press 'z'");
                 prop_name = Console.ReadLine();
                 if (prop_name == "z")
                 {
                     break;
                 }
                 while (!(B.onList(prop_name, 40)))
                 {
                     Console.WriteLine("This propriety is not in the game board !");
                     Console.WriteLine("Please write the space name correctly.");
                     Console.WriteLine("If you want to leave, press 'z'");
                     prop_name = Console.ReadLine();
                     if (prop_name == "z")
                     {
                         break;
                     }
                 }
             }
             if ((B.onList(prop_name, 40)) && (list_pr.onList(prop_name, list_pr.Size)))
             {
                 Propriety test = (Propriety)B.getSpace(B.getSpacePosition(prop_name));
                 if (test is Street)
                 {
                     Street test1 = (Street)B.getSpace(B.getSpacePosition(prop_name));
                     if (test1.house != 4)
                     {
                         Console.WriteLine("This street already doesn't have 4 houses, you can't buy a hotel !");
                     }
                     else
                     {
                         if (test1.hotel == 1)
                         {
                             Console.WriteLine("This street already have 1 hotel, you can't buy another one !");
                         }
                         else
                         {
                             Console.WriteLine("Do you want to buy a hotel in this propriety : " + test1.name + " ?");
                             Console.WriteLine("The price of a hotel is " + test1.hprice());
                             Console.WriteLine("Press 1 for yes 0 for no");
                             int resp = Convert.ToInt32(Console.ReadLine());
                             while (resp != 0 && resp != 1)
                             {
                                 Console.WriteLine("Please enter a correct awnser.");
                                 Console.WriteLine("Press 1 for yes or 0 for no. ");
                                 resp = Convert.ToInt32(Console.ReadLine());
                             }
                             if (resp == 1)
                             {
                                 if (account >= test1.hprice())
                                 {
                                     account = account - test1.hprice();
                                     test1.hotel++;
                                     B.changeSpace(B.getSpacePosition(prop_name), test1);
                                 }
                                 else
                                 {
                                     Console.WriteLine("You don't have enough money to buy this hotel !");
                                 }
                             }
                         }
                     }
                 }
                 else
                 {
                     Console.WriteLine("You can't put a hotel in this propriety, this isn't a street !");
                 }
             }
         }
     }
 }