Пример #1
0
        static void FillTours(ref string[] countries, ref TourStorage tourStrg)
        {
            // Random
            Random r = new Random();
            // Current year, month, day
            DateTime d  = DateTime.Today;
            int      cY = d.Year;
            int      cM = d.Month;
            int      cD = d.Day;

            // Random

            foreach (var i in countries)
            {
                string[] tourCountry = System.IO.File.ReadAllLines($@"C:\Users\SysRq\source\repos\KazTour\KazTour\Resourses\Hotels\{i}.txt", Encoding.UTF8);
                foreach (var item in tourCountry)
                {
                    // Country, hotel, year, month, day, number of people, number of rest days
                    Tour t = new Tour($"{i}", $"{item}", new DateTime(cY, r.Next(cM, 13), r.Next(cD, 31)), r.Next(2, 5), r.Next(3, 22), r.Next(3, 6));
                    tourStrg.AddTour(t);
                }
            }
        }
Пример #2
0
        static void BuyTour(ref TourStorage tourStrg, ref TourStorage userTours, string hotelName, ref int check)
        {
            // ToList() = magic stuff, without it doesn't work
            // https://stackoverflow.com/questions/604831/collection-was-modified-enumeration-operation-may-not-execute
            foreach (var i in tourStrg.tourStorage.ToList())
            {
                string s;
                if (i.hotel == hotelName)
                {
                    s      = "Country: " + i.country;
                    s     += "\nHotel: " + i.hotel;
                    s     += "\nDate: " + i.date.ToString("d");
                    s     += "\nPeople count: " + i.numberOfSeats;
                    s     += "\nRest days: " + i.restDays;
                    s     += "\nPrice: " + i.price;
                    s     += "\nNumber of Stars: " + i.numberOfStars + "\n";
                    check += i.price;
                    tourStrg.DeleteTourByHotelName(ref tourStrg, hotelName);
                    userTours.AddTour(i);

                    Console.WriteLine(s);
                }
            }
        }