Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class WycieczkaKraj : Wycieczka
- {
- private bool vip;
- public WycieczkaKraj(string kierunek, double cena, bool vip) : base(kierunek, cena)
- {
- this.vip = vip;
- }
- public override string ToString()
- {
- return "WycieczkaKraj: " + base.kierunek + ", cena: " + base.cena.ToString();
- }
- public override double Rabat()
- {
- return (this.cena*2)/3;
- }
- }
- class Wycieczka : IComparable<Wycieczka>
- {
- protected string kierunek;
- protected double cena;
- public Wycieczka(string kierunek, double cena)
- {
- this.kierunek = kierunek;
- this.cena = cena;
- }
- public override string ToString()
- {
- return "Wycieczka: " + this.kierunek + ", cena: " + this.cena.ToString();
- }
- public virtual double Rabat()
- {
- return this.cena / 2;
- }
- public int CompareTo(Wycieczka other)
- {
- return this.cena.CompareTo(other.cena);
- }
- }
- class Samolot
- {
- private string model;
- public Samolot(string model)
- {
- this.model = model;
- }
- }
- class Rezerwacje : IOperacje
- {
- public List<string> stos = new List<string>();
- public void Dodaj(string nazwa)
- {
- this.stos.Add(nazwa);
- }
- public void Dodaj(char ch)
- {
- this.stos.Add(ch.ToString());
- }
- public void Usun()
- {
- this.stos.RemoveAt(0);
- }
- }
- interface IOperacje
- {
- void Dodaj(string nazwa);
- void Dodaj(char ch);
- void Usun();
- }
- class Program
- {
- static void Main(string[] args)
- {
- List<Wycieczka> biuroPodrozy = new List<Wycieczka>();
- biuroPodrozy.Add(new Wycieczka("Paryz", 2000));
- biuroPodrozy.Add(new Wycieczka("Holndia", 1000));
- biuroPodrozy.Add(new Wycieczka("Belgia", 1200));
- biuroPodrozy.Add(new WycieczkaKraj("Krakow", 3200, true));
- biuroPodrozy.Add(new WycieczkaKraj("Poznan", 200, false));
- biuroPodrozy.Add(new WycieczkaKraj("Warszawa", 500, false));
- foreach(var bp in biuroPodrozy)
- {
- Console.WriteLine("rabat: " + bp.Rabat());
- }
- foreach (var bp in biuroPodrozy)
- {
- Console.WriteLine(bp.ToString());
- }
- biuroPodrozy.Sort();
- Console.WriteLine("\n\npo sotowaniu:");
- foreach (var bp in biuroPodrozy)
- {
- Console.WriteLine(bp.ToString());
- }
- biuroPodrozy.Reverse();
- Console.WriteLine("\n\nodwrocenie kolejnosci:");
- foreach (var bp in biuroPodrozy)
- {
- Console.WriteLine(bp.ToString());
- }
- Console.WriteLine("\n\nelementy o nieparzystych indeksach:");
- int index = 0;
- while(index < biuroPodrozy.Count)
- {
- if(index % 2 == 0)
- Console.WriteLine(biuroPodrozy[index]);
- index++;
- }
- Dictionary<string, float> hotel = new Dictionary<string, float>();
- hotel.Add("hotel 1", 231);
- hotel.Add("hotel 2", 1231);
- hotel.Add("hotel 3", 346);
- hotel.Add("hotel 4", 333);
- hotel.Add("hotel 5", 2356);
- Console.WriteLine("\n\nhotele:");
- foreach(var hot in hotel)
- {
- Console.WriteLine(hot.Key + " : " + hot.Value);
- }
- Queue<WycieczkaKraj> pensjonat = new Queue<WycieczkaKraj>();
- pensjonat.Enqueue(new WycieczkaKraj("Krakow", 222, false));
- pensjonat.Enqueue(new WycieczkaKraj("Gdansk", 2222, true));
- pensjonat.Enqueue(new WycieczkaKraj("Warszawa", 122, false));
- pensjonat.Enqueue(new WycieczkaKraj("Poznan", 562, false));
- pensjonat.Enqueue(new WycieczkaKraj("Lodz", 352, false));
- Console.WriteLine("\n\nelementy pensjonat: ");
- foreach(var pen in pensjonat)
- {
- Console.WriteLine(pen.ToString());
- }
- Rezerwacje rez = new Rezerwacje();
- rez.Dodaj("rezerwacja 1");
- rez.Dodaj("rezerwacja 2");
- rez.Dodaj("rezerwacja 3");
- rez.Dodaj('a');
- rez.Dodaj('b');
- rez.Dodaj('c');
- rez.Usun();
- rez.Usun();
- rez.Usun();
- Samolot samolot = new Samolot("f16");
- Console.ReadKey();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement