Example #1
0
        static void Main(string[] args)
        {
            //new object of class
            Mitarbeiter a = new Mitarbeiter(1800, "Hans");

            try
            {
                //printing properties of objects
                Console.WriteLine(a.GetName());
                Console.WriteLine(a.GetGehalt());
                //calling method and printing effects
                a.ShowGehalt(a.GetGehalt());
                Console.WriteLine(a.GetGehalt());
            }



            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            Console.WriteLine("----Task3 ab hier-----");

            //Array vom Interface type welches ein Mix aus Instanzen der Klassen enthaelt
            var test = new Abteilung[]
            {
                new Mitarbeiter(1400, "Peter"),
                new Kunden("Martha", 55),
            };

            Mitarbeiter x = (Mitarbeiter)test[0];

            Console.WriteLine(x.GetGehalt());


            Kunden y = (Kunden)test[1];

            Console.WriteLine(y.Name);


            Console.WriteLine("-----Loop Ergaenzung----");
            //Loop over array of objects
            foreach (var element in test)
            {
                Console.WriteLine(x.GetGehalt());
                Console.WriteLine(y.Name);
            }
        }
Example #2
0
        public static void Main(string[] args)
        {
            Ware a = new Ware(1, "Kartoffeln", 5.5);
            //a.Write();
            //Console.WriteLine("------------------------------------");

            Gericht b = new Gericht(2, "Gulash", 10.15, "Gemuese, Fleisch, Tomate");
            //b.Write();
            //Console.WriteLine("------------------------------------");

            Getraenk c = new Getraenk(3, "Orangensaft", 2.55, "Frei");
            //c.Write();
            //Console.WriteLine("------------------------------------");

            Personen d = new Personen(4, "Alex", "Hueber", "maennlich", "01-08-1987", 01235456, 067761141972, 1500, "Burggasse", 152 - 2, "*****@*****.**");
            //d.Write();
            //Console.WriteLine("------------------------------------");

            Kunden e = new Kunden(5, "Alex1", "Hueber1", "maennlich1", "01-08-1988", 01235457, 067761141973, 1501, "Burggasse1", 152 - 3, "*****@*****.**", 1523368);
            //e.Write();
            //Console.WriteLine("------------------------------------");

            Liferant f = new Liferant(6, "Alex2", "Hueber2", "maennlich2", "01-08-1989", 01235458, 067761141974, 1502, "Burggasse21", 1502 - 323, "*****@*****.**", 1500, "IR52668532");
            //f.Write();
            //Console.WriteLine("------------------------------------");

            MitarbeiterInnen g = new MitarbeiterInnen(7, "Alex3", "Hueber3", "maennlich3", "01-08-1990", 012354507, 0677611419553, 1501, "Burggasse5", 1515 - 3, "*****@*****.**", 1550, "Angestelle", "Kassa");
            //g.Write();
            //Console.WriteLine("------------------------------------");

            var iObjekte = new IObjekt[]
            {
                a, b, c, d, e, f, g
            };

            foreach (var item in iObjekte)
            {
                item.Write();
                Console.WriteLine("------------------------------------");
            }

            /*
             * var waren = new []
             * {
             *  new Ware(3, "Kartoffeln", 5.5m, Currency.EUR),
             *  new Ware(2, "Gulash", 10.15m, Currency.EUR),
             *  new Ware(1, "Orangensaft", 2.55m, Currency.EUR),
             * };
             *
             * var currency = Currency.EUR;
             * foreach (var x in waren)
             * {
             *  Console.WriteLine("{0} {1,-40} {2,8:0.00} {3}", x.Id, x.Titel.Truncate(40), x.GetPrice(currency), currency);
             * }
             *
             *
             *
             * var ids = waren.Select(x => x.Id).OrderBy(x => x);
             * Console.WriteLine();
             * Console.WriteLine("ID: (ordentlich)");
             * foreach (var x in ids) Console.WriteLine(x);
             */
        }