Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.93 KB | None | 0 0
  1. class WycieczkaKraj : Wycieczka
  2. {
  3. private bool vip;
  4.  
  5. public WycieczkaKraj(string kierunek, double cena, bool vip) : base(kierunek, cena)
  6. {
  7. this.vip = vip;
  8. }
  9.  
  10. public override string ToString()
  11. {
  12. return "WycieczkaKraj: " + base.kierunek + ", cena: " + base.cena.ToString();
  13. }
  14.  
  15. public override double Rabat()
  16. {
  17. return (this.cena*2)/3;
  18. }
  19.  
  20.  
  21.  
  22. }
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36. class Wycieczka : IComparable<Wycieczka>
  37. {
  38. protected string kierunek;
  39. protected double cena;
  40.  
  41. public Wycieczka(string kierunek, double cena)
  42. {
  43. this.kierunek = kierunek;
  44. this.cena = cena;
  45. }
  46.  
  47.  
  48. public override string ToString()
  49. {
  50. return "Wycieczka: " + this.kierunek + ", cena: " + this.cena.ToString();
  51. }
  52.  
  53. public virtual double Rabat()
  54. {
  55. return this.cena / 2;
  56. }
  57.  
  58. public int CompareTo(Wycieczka other)
  59. {
  60. return this.cena.CompareTo(other.cena);
  61. }
  62. }
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74. class Samolot
  75. {
  76. private string model;
  77.  
  78. public Samolot(string model)
  79. {
  80. this.model = model;
  81. }
  82. }
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92. class Rezerwacje : IOperacje
  93. {
  94.  
  95. public List<string> stos = new List<string>();
  96.  
  97. public void Dodaj(string nazwa)
  98. {
  99. this.stos.Add(nazwa);
  100. }
  101. public void Dodaj(char ch)
  102. {
  103. this.stos.Add(ch.ToString());
  104. }
  105.  
  106. public void Usun()
  107. {
  108. this.stos.RemoveAt(0);
  109. }
  110. }
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119. interface IOperacje
  120. {
  121. void Dodaj(string nazwa);
  122. void Dodaj(char ch);
  123. void Usun();
  124. }
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134. class Program
  135. {
  136. static void Main(string[] args)
  137. {
  138. List<Wycieczka> biuroPodrozy = new List<Wycieczka>();
  139.  
  140. biuroPodrozy.Add(new Wycieczka("Paryz", 2000));
  141. biuroPodrozy.Add(new Wycieczka("Holndia", 1000));
  142. biuroPodrozy.Add(new Wycieczka("Belgia", 1200));
  143.  
  144. biuroPodrozy.Add(new WycieczkaKraj("Krakow", 3200, true));
  145. biuroPodrozy.Add(new WycieczkaKraj("Poznan", 200, false));
  146. biuroPodrozy.Add(new WycieczkaKraj("Warszawa", 500, false));
  147.  
  148.  
  149. foreach(var bp in biuroPodrozy)
  150. {
  151. Console.WriteLine("rabat: " + bp.Rabat());
  152. }
  153.  
  154. foreach (var bp in biuroPodrozy)
  155. {
  156. Console.WriteLine(bp.ToString());
  157. }
  158.  
  159.  
  160. biuroPodrozy.Sort();
  161.  
  162. Console.WriteLine("\n\npo sotowaniu:");
  163. foreach (var bp in biuroPodrozy)
  164. {
  165. Console.WriteLine(bp.ToString());
  166. }
  167.  
  168. biuroPodrozy.Reverse();
  169.  
  170. Console.WriteLine("\n\nodwrocenie kolejnosci:");
  171. foreach (var bp in biuroPodrozy)
  172. {
  173. Console.WriteLine(bp.ToString());
  174. }
  175.  
  176. Console.WriteLine("\n\nelementy o nieparzystych indeksach:");
  177. int index = 0;
  178.  
  179. while(index < biuroPodrozy.Count)
  180. {
  181. if(index % 2 == 0)
  182. Console.WriteLine(biuroPodrozy[index]);
  183. index++;
  184. }
  185.  
  186. Dictionary<string, float> hotel = new Dictionary<string, float>();
  187.  
  188. hotel.Add("hotel 1", 231);
  189. hotel.Add("hotel 2", 1231);
  190. hotel.Add("hotel 3", 346);
  191. hotel.Add("hotel 4", 333);
  192. hotel.Add("hotel 5", 2356);
  193.  
  194. Console.WriteLine("\n\nhotele:");
  195. foreach(var hot in hotel)
  196. {
  197. Console.WriteLine(hot.Key + " : " + hot.Value);
  198. }
  199.  
  200. Queue<WycieczkaKraj> pensjonat = new Queue<WycieczkaKraj>();
  201.  
  202. pensjonat.Enqueue(new WycieczkaKraj("Krakow", 222, false));
  203. pensjonat.Enqueue(new WycieczkaKraj("Gdansk", 2222, true));
  204. pensjonat.Enqueue(new WycieczkaKraj("Warszawa", 122, false));
  205. pensjonat.Enqueue(new WycieczkaKraj("Poznan", 562, false));
  206. pensjonat.Enqueue(new WycieczkaKraj("Lodz", 352, false));
  207.  
  208. Console.WriteLine("\n\nelementy pensjonat: ");
  209. foreach(var pen in pensjonat)
  210. {
  211. Console.WriteLine(pen.ToString());
  212. }
  213.  
  214.  
  215. Rezerwacje rez = new Rezerwacje();
  216.  
  217. rez.Dodaj("rezerwacja 1");
  218. rez.Dodaj("rezerwacja 2");
  219. rez.Dodaj("rezerwacja 3");
  220.  
  221. rez.Dodaj('a');
  222. rez.Dodaj('b');
  223. rez.Dodaj('c');
  224.  
  225. rez.Usun();
  226. rez.Usun();
  227. rez.Usun();
  228.  
  229. Samolot samolot = new Samolot("f16");
  230.  
  231. Console.ReadKey();
  232. }
  233.  
  234.  
  235. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement