Advertisement
Guest User

Untitled

a guest
Jan 21st, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.25 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace KolokwiumL3
  7. {
  8. public class Osoba
  9. {
  10. public string Imie { get; set; }
  11. public string Nazwisko { get; set; }
  12.  
  13. public Osoba(string Imie, string Nazwisko)
  14. {
  15. this.Imie = Imie;
  16. this.Nazwisko = Nazwisko;
  17. }
  18. }
  19.  
  20. public class Samochod
  21. {
  22. public string Marka { get; set; }
  23. public int RokProdukcji { get; set; }
  24. public bool Dostepnosc { get; set; }
  25. public Osoba Wlasciciel { get; set; }
  26.  
  27. public Samochod()
  28. {
  29. this.Wlasciciel = new Osoba(null, null);
  30. }
  31.  
  32. public Samochod(string Marka, int RokProdukcji)
  33. {
  34. this.Marka = Marka;
  35. this.RokProdukcji = RokProdukcji;
  36. this.Wlasciciel = new Osoba(null, null);
  37. this.Dostepnosc = true;
  38. }
  39.  
  40. public string CzyDostepny()
  41. {
  42. if (Dostepnosc == false)
  43. {
  44. return string.Format("Sprzedany");
  45. }
  46. else
  47. {
  48. return string.Format("Dostepny");
  49. }
  50. }
  51.  
  52. public void Sprzedaj(string Imie, string Nazwisko)
  53. {
  54. this.Wlasciciel = new Osoba(Imie, Nazwisko);
  55. this.Dostepnosc = false;
  56. }
  57.  
  58. public string InfoSamochod()
  59. {
  60. if (Dostepnosc == false)
  61. {
  62. return string.Format("Samochod marki {0} rok produkcji {1}, jest {2} panu/pani {3} {4}", Marka, RokProdukcji, CzyDostepny(), Wlasciciel.Imie, Wlasciciel.Nazwisko);
  63. }
  64. else
  65. {
  66. return string.Format("Samochod marki {0} rok produkcji {1}, jest {2}", Marka, RokProdukcji, CzyDostepny());
  67. }
  68. }
  69. }
  70.  
  71. class Program
  72. {
  73. static void Main(string[] args)
  74. {
  75. Samochod samochod = new Samochod("Opel",2018);
  76. Console.WriteLine(samochod.InfoSamochod());
  77.  
  78. Console.WriteLine(samochod.Sprzedaj("Krystian","Mlynek"));
  79.  
  80. Console.WriteLine(samochod.InfoSamochod());
  81. Console.ReadKey();
  82.  
  83.  
  84. }
  85. }
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement