Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Base
- {
- virtual public void who()
- {
- Console.WriteLine("Metoda w klase Base");
- }
- }
- class Derived1 : Base
- {
- override public void who()
- {
- Console.WriteLine("Metoda w kalsie der1");
- }
- }
- class Derived2 : Derived1
- {
- //gdy metoda jest zakomentowana uruchomi sie metoda z klasy base
- override public void who()
- {
- Console.WriteLine("Metoda w kalsie der2");
- }
- }
- class Derived3 : Derived2
- {
- //override public void who()
- //{
- // Console.WriteLine("Metoda w kalsie der3");
- //}
- }
- //zadanie 3
- //metody zostano wywolanez klasy der1
- class demo
- {
- public static void Main()
- {
- Base baseob = new Base();
- Derived1 ob1 = new Derived1();
- Derived2 ob2 = new Derived2();
- Derived3 ob3 = new Derived3();
- Base objref = baseob;
- objref.who();
- objref = ob1;
- objref.who();
- objref = ob2;
- objref.who();
- objref = ob3;
- objref.who();
- Console.ReadKey();
- }
- }
- //abstract class TwoD
- //{
- // public int wysokosc;
- // public int szerokosc;
- // abstract public int Area();
- // public void set(int w, int h)
- // {
- // wysokosc = w;
- // szerokosc = h;
- // }
- //}
- //class Tri : TwoD
- //{
- // override public int Area()
- // {
- // return wysokosc * szerokosc / 2;
- // }
- //}
- //class Rec : TwoD
- //{
- // override public int Area()
- // {
- // return wysokosc * szerokosc;
- // }
- //}
- //class Demo
- //{
- // public static void Main()
- // {
- // TwoD szejp;
- // Tri tr = new Tri();
- // Rec re = new Rec();
- // tr.set(2, 4);
- // szejp = tr;
- // Console.WriteLine(szejp.Area());
- // re.set(2, 4);
- // szejp = re;
- // Console.WriteLine(szejp.Area());
- // Console.ReadKey();
- // }
- //}
- // class Box
- //{
- // public static void Main()
- // {
- // int x = 10;
- // Console.WriteLine(x);
- // x = sqr(x);
- // Console.WriteLine(x);
- // Console.ReadKey();
- // }
- // static int sqr(object o)
- // {
- // return (int) o * (int) o;
- // }
- //}
- //class Generic
- //{
- // public static void Main()
- // {
- // object[] ga = new object [10];
- // for (int i = 0; i < 3; i++)
- // {
- // int number = i + i * i;
- // ga[i] = number;
- // }
- // for (int i = 3; i < 6; i++)
- // {
- // double number = (double)i/3;
- // ga[i] = number;
- // }
- // ga[6] = "Tablica stringow";
- // ga[7] = true;
- // ga[8] = 'x';
- // ga[9] = "Koniec";
- //http://boards.4chan.org/trash/
- // for(int i =0;i<10;i++)
- // {
- // Console.WriteLine(ga[i]);
- // }
- // Console.ReadKey();
- // }
- //}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement