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 ConsoleApp5
- {
- class Car
- {
- public int Rok;
- public string Marka;
- private string model;
- private int iloscdrzwi;
- private string pojemnoscsilnika;
- public double sredniespalanie;
- // Obliczspalanie ex 9
- public double ObliczSpalanie(double dlugosctrasy)
- {
- return sredniespalanie * dlugosctrasy;
- }
- //ObliczkosztPrzejazdu ex 10
- public double ObliczKosztPrzejazdu(double dlugoscTrasy, double cenaPaliwa)
- {
- double x = ObliczSpalanie(dlugoscTrasy);
- return x * cenaPaliwa;
- }
- }
- class Osoba
- {
- public string imie;
- public string nazwisko;
- public int rokUrodzenia;
- public int waga;
- public int wzrost;
- public bool okulary;
- public int plec;
- public int obliczwiek()
- {
- return DateTime.Now.Year - rokUrodzenia;
- }
- public string przedrostek()
- {
- if (plec == 0)
- {
- return "Pan ";
- }
- else
- return "Pani";
- }
- public string BMI()
- {
- wzrost = wzrost / 100;
- double BMI = waga / (wzrost ^ 2);
- Console.WriteLine(BMI);
- if (BMI > 30)
- {
- return "Otyłość";
- }
- else if (BMI >= 25 & BMI <= 30)
- {
- return "Nadwaga";
- }
- else if (BMI >= 18.5 & BMI < 25)
- {
- return "Norma";
- }
- else
- return "Niedowaga";
- }
- }
- class produkt
- {
- public string nazwa;
- public int cena;
- }
- //class koszyk
- //{
- // public string listatowarow;
- //}
- //public void dokoszyka(produkt x)
- //{
- // koszyk produkt = new koszyk();
- //}
- class Zespolone
- {
- public int x;
- public int y;
- public void wypisz()
- {
- if (y >= 0)
- {
- Console.WriteLine(x + "+" + y+"i");
- }
- else if (y < 0)
- {
- Console.WriteLine(x + "-" + y+"i");
- }
- else
- Console.WriteLine(x);
- }
- public void dodawanie(int p, int q)
- {
- x = p + x;
- y = q + y;
- }
- public void mnozenie(int p, int q)
- {
- x = (x * p) - (y * q);
- y = (x*q) + (p*y);
- }
- }
- class Program
- {
- //opisz typ 11
- static void OpiszTyp()
- {
- Console.WriteLine("Jest to typ bez argumentu");
- }
- static void OpiszTyp(int x)
- {
- Console.WriteLine("Jest to typ int");
- }
- static void OpiszTyp(double x, double y)
- {
- Console.WriteLine("Jest to typ double z 2 zmiennymi");
- }
- static void OpiszTyp(string x)
- {
- Console.WriteLine("Jest to typ string");
- }
- static void Main(string[] args)
- {
- //ex1
- string carName = "Mój samochód";
- Console.WriteLine(carName);
- // ex 4
- Car car1 = new Car();
- car1.Rok = 1999;
- car1.Marka = "Pogo";
- Console.WriteLine("Car1 = " + car1.Rok + " " + car1.Marka);
- car1.sredniespalanie = 5;
- // ex 5,6
- Car car2 = new Car();
- car2.Rok = 1;
- car2.Marka = "Dino";
- Console.WriteLine("Car2 = " + car2.Rok + " " + car2.Marka);
- car1 = car2;
- Console.WriteLine("Car1 = " + car1.Rok + " " + car1.Marka);
- Console.WriteLine("Car2 = " + car2.Rok + " " + car2.Marka);
- Console.WriteLine("spalanie " + car1.ObliczSpalanie(80));
- Console.WriteLine("koszt przejazdu " + car1.ObliczKosztPrzejazdu(10, 900));
- OpiszTyp();
- OpiszTyp(5);
- OpiszTyp(40.2, 50.2);
- OpiszTyp("Zdanie");
- //Dyrektor
- Osoba Dyrektor = new Osoba();
- Dyrektor.imie = "Grozna";
- Dyrektor.nazwisko = "Wozna";
- Dyrektor.plec = 1;
- Console.WriteLine("Dyrektor " + Dyrektor.przedrostek() + " " + Dyrektor.imie + " " + Dyrektor.nazwisko + " w wieku " + Dyrektor.obliczwiek());
- //Pacjent
- Osoba Pacjent = new Osoba();
- Pacjent.imie = "jan";
- Pacjent.nazwisko = "kowalski";
- Pacjent.wzrost = 180;
- Pacjent.waga = 70;
- Console.WriteLine("BMI pacjenta wynosi " + Pacjent.BMI());
- produkt kanapka = new produkt();
- kanapka.cena = 150;
- kanapka.nazwa = "kanapka";
- //koszyk koszyczek = new koszyk();
- //koszyczek.dokoszyka(kanapka);
- Zespolone liczba = new Zespolone();
- liczba.x = 5;
- liczba.y = 2;
- liczba.dodawanie(3, 4);
- liczba.wypisz();
- liczba.mnozenie(3, 4);
- liczba.wypisz();
- Console.ReadLine();
- }
- }
- }
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace produkt_i_koszyk
- {
- class Program
- {
- public abstract class SD
- {
- protected string[] dane;
- public int Length
- {
- get;
- protected set;
- }
- public SD()
- {
- this.Length = 0;
- this.dane = new string[this.Length];
- }
- }
- public class Produkt
- {
- public string nazwa;
- }
- public class Koszyk : SD
- {
- public void Push(string element)
- {
- this.Length++;
- string[] tmp = this.Przepisz(this.dane);
- tmp[Length - 1] = element;
- dane = tmp;
- }
- protected string[] Przepisz(string[] stara)
- {
- string[] nowa = new string[stara.Length + 1];
- for(int i=0; i < stara.Length; i++)
- {
- nowa[i] = stara[i];
- }
- return nowa;
- }
- public void lista()
- {
- for (int i = 0; i < Length; i++) {
- Console.WriteLine(dane[i]);
- }
- }
- }
- static void Main(string[] args)
- {
- Produkt ziemniak = new Produkt();
- ziemniak.nazwa = "Ziemniak";
- Produkt makaron = new Produkt();
- makaron.nazwa = "Makaron";
- Produkt krab = new Produkt();
- krab.nazwa = "Krab";
- Koszyk koszyk = new Koszyk();
- koszyk.Push(makaron.nazwa);
- koszyk.Push(ziemniak.nazwa);
- koszyk.Push(krab.nazwa);
- Console.WriteLine(koszyk.Length);
- koszyk.lista();
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement