Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.84 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Projekt_Szarp
  8. {
  9. public class Osoba
  10. {
  11. private string Nazwisko;
  12. private int Wiek;
  13.  
  14. public string nazwisko
  15. {
  16. get { return Nazwisko; }
  17. set { Nazwisko = value; }
  18. }
  19. public int wiek
  20. {
  21. get { return Wiek; }
  22. set { Wiek = value; }
  23. }
  24. public Osoba(string nazwisko, int wiek)
  25. {
  26. this.nazwisko = nazwisko;
  27. this.wiek = wiek;
  28. }
  29. public Osoba() { }
  30. public Osoba(Osoba o)
  31. {
  32. this.nazwisko = o.nazwisko;
  33. this.wiek = o.wiek;
  34.  
  35. }
  36. public void Wypisz()
  37. {
  38. Console.WriteLine("Podaj nazwisko");
  39. this.nazwisko = Console.ReadLine();
  40. Console.WriteLine("Podaj wiek");
  41. this.wiek = int.Parse(Console.ReadLine());
  42.  
  43. }
  44. public override string ToString()
  45. {
  46. string znak;
  47. znak = string.Format("{0} {1}", nazwisko, wiek);
  48. return znak;
  49. }
  50. public class Student : Osoba
  51. {
  52. private string Uczelnia;
  53. private string Wydzial;
  54. private int rok;
  55.  
  56. public string uczelnia
  57. {
  58. get { return Uczelnia; }
  59. set { Uczelnia = value; }
  60.  
  61. }
  62. public Student(string uczelnia, int wiek, int rok, string wydzial, string nazwisko)
  63. {
  64. this.nazwisko = nazwisko;
  65. this.wiek = wiek;
  66. this.Uczelnia = uczelnia;
  67. this.Wydzial = wydzial;
  68. this.rok = rok;
  69.  
  70. }
  71. new public void Wypisz()
  72. {
  73. Console.WriteLine("Dane studenta");
  74. Console.WriteLine("Podaj uczelnie");
  75. this.Uczelnia = Console.ReadLine();
  76. Console.WriteLine("Podaj Wydzial");
  77. this.Wydzial = Console.ReadLine();
  78. Console.WriteLine("Podaj rok");
  79. this.rok = int.Parse(Console.ReadLine());
  80. Console.WriteLine("Podaj nazwisko");
  81. this.nazwisko = Console.ReadLine();
  82. Console.WriteLine("Podaj wiek");
  83. this.wiek = int.Parse(Console.ReadLine());
  84. Console.WriteLine(Uczelnia, Wydzial, rok, nazwisko, wiek);
  85. }
  86. }
  87.  
  88. static void Main(string[] args)
  89. {
  90.  
  91. Osoba o1 = new Osoba("Example", 1);
  92. Console.WriteLine(o1);
  93.  
  94. Student s1 = new Student("Politechnika", 2, 3, "Poli", "Cos");
  95. s1.Wypisz();
  96. Console.WriteLine(s1);
  97. }
  98.  
  99. }
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement