Exemplo n.º 1
0
        static void Main(string[] args)
        {
            //Car2 car = new Car2(){Color = "Yellow", Speed = 100, Wheel = 4};
            Car2 car2 = new Car2()
            {
                Color = "Blue", Speed = 150, Wheel = 8
            };
            Center center = new Center(car2);

            center.PrintCar(car2);
            Message message = new Message();

            car2.SetCar += message.OnStopCar;

            StreamWriter writer = new StreamWriter(@"C:\wamp\filen.txt");

            writer.Write("Detta ska in i filen");
            writer.Close();
            StreamReader reader = new StreamReader(@"C:\wamp\filen.txt");
            string       rr     = reader.ReadLine();

            Console.WriteLine(rr);
            center.PrintCar(car2);
            car2.SetSpeed(120);
            center.PrintCar(car2);
            center.StopCar(car2);

            center.PrintCar(car2);
            IList <Animal> lok = new List <Animal>();

            lok.Add(new Animal()
            {
                Age = 42, Name = "pol"
            });
            lok.Add(new Animal()
            {
                Age = 424, Name = "def"
            });



            Rr nunu = new Rr();

            nunu.vw(new Computer2());



            var program = new Program().Fff();

            var s = program.FindAll(p => p.Age > 33);

            foreach (var animal in s)
            {
                Console.WriteLine(animal.Age);
            }


            //Person p = new Person()
            //{
            //    Address = "Kust"
            //};

            //Indian a = new Indian()
            //{
            //    Name = "Jorgen",
            //    Age = 45
            //};

            //List<Animal> members = new List<Animal>();
            //members.Add(a);
            //members.Add(p);
            //foreach (var item in members)
            //{
            //    if (item is Indian)
            //    {
            //        Animal aa = item as Indian;

            //        aa.MyName("JOr");
            //        Console.WriteLine(aa.Name);

            //    }
            //    if (item is Person)
            //    {
            //        Person pp = item as Person;

            //        pp.MyName("Lotta");
            //    }
            //}

            //foreach (var it in members)
            //{
            //    it.MyName("hepp");
            //}

            //Animal animal = new Person();
            //Person p = new Person();
            //var f = animal is Person;


            Console.ReadLine();
        }
Exemplo n.º 2
0
        public void OnStopCar(object sender, SpeedEventArgs e)
        {
            Car2 car = (Car2)sender;

            Console.WriteLine($"Följande har stannat: {car.Speed  + " " + car.Color} and speed args {e.Speed}");
        }