Example #1
0
        static void PushExample()
        {
            Subject <Airplane> source = new Subject <Airplane>();

            source
            .Sample(TimeSpan.FromSeconds(2.0))
            .Subscribe(x => Console.WriteLine($"read {x}\n"))
            ;

            //source
            //    .Where(x => x.Length > 50)
            //    .Subscribe(x => Console.WriteLine($"read {x}\n"))
            //    ;

            //source
            //    .Skip(4)
            //    .Subscribe(x => Console.WriteLine($"read {x}\n"))
            //    ;

            Thread t = new Thread(() =>
            {
                Random r = new Random();
                while (true)
                {
                    double fuel_level = r.NextDouble() * 10000;
                    double wingspan   = r.NextDouble() * 100;
                    double length     = r.NextDouble() * 100;
                    Airplane a        = new Airplane(fuel_level, wingspan, length);
                    Console.WriteLine($"added {a}\n");
                    source.OnNext(a);
                    Thread.Sleep(1000);
                }
            });

            t.Start();
        }
Example #2
0
 //Constructor
 public Flight(string fc, string fd, string dT, string dA, string aT, string desA, double price, Airplane plane)
 {
     this.flightCode         = fc;
     this.flightDate         = fd;
     this.departureTime      = dT;
     this.departureAirport   = dA;
     this.arrivalTime        = aT;
     this.destinationAirport = desA;
     this.price = price;
     this.plane = plane;
     number++;
 }