Advertisement
Guest User

samochod

a guest
Feb 25th, 2020
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.IO;
  6.  
  7. namespace Lab1
  8. {
  9. public class samochod
  10. {
  11. int predkosc;
  12. string model, marka, rejestracja;
  13. kierowca[] auto = new kierowca[4];
  14. public samochod(int a, string b, string c, string d)
  15. {
  16. predkosc = a;
  17. model = b;
  18. marka = c;
  19. rejestracja = d;
  20. }
  21. public void dodajDoAuta(kierowca k, int miejsce)
  22. {
  23. auto[miejsce] = k;
  24. }
  25. public void wypisz(int miejsce)
  26. {
  27. kierowca k = auto[miejsce];
  28. Console.WriteLine("Prędkość maksymalna: " + predkosc + "km/h " + "Model: " + model + " " + "Marka: " + marka + " " + "Rejestracja: " + rejestracja);
  29. }
  30. public void wypiszKierowce(int miejsce)
  31. {
  32. kierowca k = auto[miejsce];
  33. Console.WriteLine(k.GetImie() + " " + k.GetNazwisko());
  34. }
  35. }
  36. public class kierowca
  37. {
  38. string imie, nazwisko;
  39. public kierowca(string a, string b)
  40. {
  41. imie = a;
  42. nazwisko = b;
  43. }
  44. public string GetImie()
  45. {
  46. return imie;
  47. }
  48. public string GetNazwisko() {
  49. return nazwisko;
  50. }
  51. }
  52. class Program
  53. {
  54. static void Main(string[] args)
  55. {
  56. samochod s1 = new samochod(170, "Fiat", "Panda", "LB48469");
  57. kierowca k1 = new kierowca("Zbigniew", "Iwaniuk");
  58. kierowca k2 = new kierowca("Ola", "Nowak");
  59. s1.dodajDoAuta(k1, 1);
  60. s1.dodajDoAuta(k2, 2);
  61. s1.wypiszKierowce(1);
  62. s1.wypiszKierowce(2);
  63. s1.wypisz(1);
  64. Console.ReadKey();
  65. }
  66. }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement