コード例 #1
0
        public ITrip CreateTrip()
        {
            Random        random = new Random();
            IAccomodation hotel;
            ITrip         trip = new Trip(random.Next(1, 5));

            for (int i = 0; i < trip.DaysCount; i++)
            {
                if (bookingIterator.HasNext())
                {
                    hotel = bookingIterator.GetCurrent();
                }
                else
                {
                    bookingIterator.Reset();
                    if (!bookingIterator.HasNext())
                    {
                        trip.Hotels.Add(new Hotel());
                        continue;
                    }
                    hotel = bookingIterator.GetCurrent();
                }


                hotel.Price  = bookingDescrambler.Handle(hotel.Price);
                hotel.Rating = bookingDescrambler.Handle(hotel.Rating);
                trip.Hotels.Add(hotel);
            }

            return(trip);
        }
コード例 #2
0
        public IReview CreateReview()
        {
            if (oysteIterator.HasNext())
            {
                return(oysteIterator.GetCurrent());
            }

            oysteIterator.Reset();
            if (!oysteIterator.HasNext())
            {
                return(new Review());
            }
            return(oysteIterator.GetCurrent());
        }
コード例 #3
0
        public IPhoto CreatePhoto()
        {
            IPhoto photo;

            if (stockIterator.HasNext())
            {
                photo = stockIterator.GetCurrent();
            }
            else
            {
                stockIterator.Reset();
                if (!stockIterator.HasNext())
                {
                    return(new Photo());
                }
                photo = stockIterator.GetCurrent();
            }
            photo.WidthPx  = stockDescrambler.Handle(photo.WidthPx);
            photo.HeightPx = stockDescrambler.Handle(photo.HeightPx);
            return(photo);
        }
コード例 #4
0
        public ITrip CreateTrip()
        {
            ITrip trip = travelAgency.CreateTrip();

            trip.Country = "Poland";
            IAttraction attraction;

            for (int i = 0; i < trip.DaysCount; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    do
                    {
                        if (tripAdvisorIterator.HasNext())
                        {
                            attraction        = tripAdvisorIterator.GetCurrent();
                            attraction.Rating = tripAdvisorDescrambler.Handle(attraction.Rating);
                            attraction.Price  = tripAdvisorDescrambler.Handle(attraction.Price);
                        }
                        else
                        {
                            tripAdvisorIterator.Reset();
                            if (!tripAdvisorIterator.HasNext())
                            {
                                attraction = new Attraction();
                                break;
                            }
                            attraction        = tripAdvisorIterator.GetCurrent();
                            attraction.Rating = tripAdvisorDescrambler.Handle(attraction.Rating);
                            attraction.Price  = tripAdvisorDescrambler.Handle(attraction.Price);
                        }
                    } while (attraction.Country != "Poland");


                    trip.Attractions[i].Add(attraction);
                }
            }
            return(trip);
        }