Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace kolo3
- {
- class Program
- {
- public void getType() { Console.WriteLine("Wczytano void"); }
- public void getType(int a) { Console.WriteLine("Wczytano integer"); }
- public void getType(string a) { Console.WriteLine("Wczytano string"); }
- public void getType(int a, string b) { Console.WriteLine("Wczytano integer & string"); }
- public void getType(bool a) { Console.WriteLine("Wczytano Boolean"); }
- public void getType(int a, int b, bool c) { Console.WriteLine("Wczytano 2 x integer & Boolean"); }
- //#################################################################//
- public enum typTrasy {krotka = 8, dluga = 13}
- class Samochod
- {
- private float pojemnoscSilnika;
- private string nrVIN;
- public int rocznik;
- public string nazwa;
- public float srednieSpalanie;
- private Samochod() { }
- public void Create(float _a, string _b, int _c, string _d, float _e)
- {
- this.pojemnoscSilnika = _a;
- this.nrVIN = _b;
- this.rocznik = _c;
- this.nazwa = _d;
- this.srednieSpalanie = _e;
- }
- public void ObliczSpalanie(int lenght, typTrasy trasa )
- {
- Console.WriteLine("Spalanie tego samocodu to: {0}", (this.srednieSpalanie * lenght * ((int)trasa / 10)));
- }
- }
- //#################################################################//
- class Kalkulator
- {
- private int a, b;
- public Kalkulator() { }
- public Kalkulator(int _a)
- {
- this.a = _a;
- }
- public Kalkulator(int _a, int _b)
- {
- this.a = _a;
- this.b = _b;
- }
- private int Dodaj(){ return this.a + this.b; }
- private int Odejmij() { return this.a - this.b; }
- private int Dziel() { return (int)(this.a / this.b); }
- private int Pomnuz() { return this.a * this.b; }
- }
- class DziwnyKalkulator : Kalkulator
- {
- public int a, b, c;
- public DziwnyKalkulator() { }
- public DziwnyKalkulator(int _a)
- {
- this.a = _a;
- }
- public DziwnyKalkulator(int _a, int _b)
- {
- this.a = _a;
- this.b = _b;
- }
- public DziwnyKalkulator(int _a, int _b, int _c)
- {
- this.a = _a;
- this.b = _b;
- this.c = _c;
- }
- public int Dodawanie(int x, int y)
- {
- return x + y;
- }
- public void DodawanieModulo26()
- {
- Console.WriteLine("{0}", (this.a % 26 + this.b % 26) % 26);
- }
- public void Pierwiastkowanie()
- {
- Console.WriteLine("{0}", Math.Sqrt(this.a));
- }
- public void PodwojneDodawanie()
- {
- Console.WriteLine("{0}", this.Dodawanie(a, Dodawanie(b, c)));
- }
- }
- //#################################################################//
- class Pracownik
- {
- public string imie;
- public string nazwisko;
- public double zarobki;
- public Pracownik() { }
- public Pracownik(string _imie, string _nazwisko, double _zarobki)
- {
- this.imie = _imie;
- this.nazwisko = _nazwisko;
- this.zarobki = _zarobki;
- }
- public virtual void Pracuj()
- {
- Console.WriteLine("Pracownik teraz pracuje");
- }
- }
- class Skrzypek : Pracownik
- {
- public Skrzypek(string imie, string nazwisko, double zarobki)
- : base(imie, nazwisko, zarobki)
- {
- base.imie = imie;
- base.nazwisko = nazwisko;
- base.zarobki = zarobki;
- }
- public override void Pracuj()
- {
- Console.WriteLine("Skrzypek skrzypi");
- }
- }
- class Ksiegowa : Pracownik
- {
- public Ksiegowa(string imie, string nazwisko, double zarobki)
- : base(imie, nazwisko, zarobki)
- {
- base.imie = imie;
- base.nazwisko = nazwisko;
- base.zarobki = zarobki;
- }
- public override void Pracuj()
- {
- Console.WriteLine("Księgowa się obija");
- }
- }
- class Sprzedawca : Pracownik
- {
- public Sprzedawca(string imie, string nazwisko, double zarobki)
- : base(imie, nazwisko, zarobki)
- {
- base.imie = imie;
- base.nazwisko = nazwisko;
- base.zarobki = zarobki;
- }
- public override void Pracuj()
- {
- Console.WriteLine("Sprzedawca się sprzedaje");
- }
- //#################################################################//
- interface IClonable
- {
- Object Clone();
- }
- interface IFigure
- {
- string ToString();
- void LiczObwod();
- }
- class Punkt : IClonable, IFigure
- {
- public int x, y;
- public Punkt () { }
- public Punkt(int _x, int _y) { this.x = _x; this.y = _y; }
- public object Clone()
- {
- return this.MemberwiseClone();
- }
- public override string ToString()
- {
- return "To jest punkt o współrzędnych <" + x.ToString() + y.ToString() + ">";
- }
- public void LiczFigure()
- {
- Console.WriteLine("Obwod = 0");
- }
- }
- class Kolo : IClonable, IFigure
- {
- public int srodek_x, srodek_y, promien;
- public Kolo() { }
- public Kolo(int _a, int _b, int _c) { this.srodek_x = _a; this.srodek_y = _b; this.promien = _c; }
- public object Clone()
- {
- return this.MemberwiseClone();
- }
- public override string ToString()
- {
- return "To jest punkt o srodku <" + srodek_x.ToString() + srodek_y.ToString() + "> i promieniu r = " + promien.ToString();
- }
- public void LiczFigure()
- {
- Console.WriteLine("Obwod = {0}", (2 * Math.PI * this.promien) );
- }
- }
- class Kwadrat : IClonable, IFigure
- {
- public int a_x, a_y, b_x, b_y, c_x, c_y, d_x, d_y;
- public Kwadrat() { }
- public Kwadrat(int _a, int _b, int _c, int _d, int _e, int _f, int _g, int _h)
- {
- this.a_x = _a; this.a_y = _b;
- this.b_x = _c; this.b_y = _d;
- this.c_x = _e; this.c_y = _f;
- this.d_x = _g; this.d_y = _h;
- }
- public object Clone()
- {
- return this.MemberwiseClone();
- }
- public override string ToString()
- {
- return "To jest punkt o naroznikach <" + a_x.ToString() + a_y.ToString() + "> <" + b_x.ToString() + b_y.ToString()
- + "> <" + c_x.ToString() + c_y.ToString() + "> <" + d_x.ToString() + d_y.ToString();
- }
- public void LiczFigure()
- {
- int obwod = (this.a_x - this.d_x) + (this.b_y - this.a_y) + (this.c_y - this.d_y) + (this.b_x - this.c_x);
- Console.WriteLine("Obwod = {0}", obwod);
- }
- }
- }
- static void Main(string[] args)
- {
- //#################################################################//
- Type cars = typeof(Samochod);
- Samochod car = (Samochod)Activator.CreateInstance(cars, true);
- car.Create(1.4F, "a", 1234, "b", 1.1F);
- car.ObliczSpalanie(100, typTrasy.dluga);
- //#################################################################//
- Type abc = typeof(Program);
- Program one = (Program)Activator.CreateInstance(abc, true);
- one.getType(true);
- one.getType(1, "napis");
- one.getType(1, 1, true);
- one.getType("napis");
- one.getType(1);
- //#################################################################//
- DziwnyKalkulator k = new DziwnyKalkulator(100);
- k.Pierwiastkowanie();
- DziwnyKalkulator k2 = new DziwnyKalkulator(40, 1);
- k2.DodawanieModulo26();
- DziwnyKalkulator k3 = new DziwnyKalkulator(40, 1, 7);
- k3.PodwojneDodawanie();
- //#################################################################//
- List<Pracownik> LISTA = new List<Pracownik>();
- LISTA.Add(new Skrzypek("andrzej", "nie ma", 33.3));
- LISTA.Add(new Sprzedawca("janusz", "abc", 66.6));
- LISTA.Add(new Ksiegowa("mariola", "xdxd", 99.9));
- foreach (Pracownik NaLiscie in LISTA)
- {
- NaLiscie.Pracuj();
- }
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement