using static System.Console;
namespace Zad6_3
{
class Program : Pro
{
public string ms1 = "To jest zmienna publiczna";
public void print(string ms)
{
WriteLine($"Tu drukuję parametr: {ms}");
}
public void print(int i)
{
WriteLine("Ta metoda robi co innego - zwraca i*2");
WriteLine(i * 2);
}
static void Main(string[] args)
{
WriteLine("Abstrakcja");
WriteLine("Instancja klasy Human - nie da się utworzyć bezpośrednio");
//Human human = new Human();
WriteLine("Instancja klasy Student");
Student stud
= new Student
();
WriteLine("Czy obudzony: " + stud.awakeness());
stud.goToSleep();
WriteLine("Czy obudzony: " + stud.awakeness());
WriteLine();
WriteLine("Hermetyzacja");
Program pub
= new Program
();
Inter inter
= new Inter
();
ProInc proInc
= new ProInc
();
//WriteLine(pri.ms3);
WriteLine(pub.ms2 + ", do której mamy dostęp przez klasę dziedziczącą");
//WriteLine(pub.ms3 + ", do której mamy dostęp przez klasę dziedziczącą");
WriteLine();
WriteLine(inter.ms4 + ", dostęp poza klasą, poprzez obiekt");
WriteLine(proInc.ms5 + ", dostęp poza klasą, poprzez obiekt");
WriteLine();
WriteLine("Dziedziczenie");
cat.setName("Filemon");
WriteLine(cat.name);
WriteLine(cat.talk());
WriteLine();
WriteLine("Polimorfizm");
pub.print("Moja wiadomość");
pub.print(10);
Read();
}
}
abstract class Human
{
abstract public void goToSleep();
}
class Student
{
bool awaken = true;
public void goToSleep()
{
awaken = false;
}
public bool awakeness()
{
return awaken;
}
}
class Pro : Pri
{
protected string ms2 = "To jest zmienna chroniona (protected)";
}
class Pri
{
private string ms3 = "To jest zmienna prywatna";
public string getPri()
{
return ms3;
}
}
class Inter
{
internal string ms4 = "To jest zmienna wewnętrzna (internal)";
}
class ProInc
{
protected internal string ms5 = "To jest zmienna chroniona wewnętrzna (protected internal)";
}
public class Animal
{
public string name = "Mam na imię ";
public string setName(string name)
{
this.name += name;
return name;
}
public string roar()
{
return "";
}
}
public class Cat : Animal
{
public string talk()
{
return "Meow, meow";
}
}
}
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}