Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Projekt_Szarp
- {
- public class Osoba
- {
- private string Nazwisko;
- private int Wiek;
- public string nazwisko
- {
- get { return Nazwisko; }
- set { Nazwisko = value; }
- }
- public int wiek
- {
- get { return Wiek; }
- set { Wiek = value; }
- }
- public Osoba(string nazwisko, int wiek)
- {
- this.nazwisko = nazwisko;
- this.wiek = wiek;
- }
- public Osoba() { }
- public Osoba(Osoba o)
- {
- this.nazwisko = o.nazwisko;
- this.wiek = o.wiek;
- }
- public void Wypisz()
- {
- Console.WriteLine("Podaj nazwisko");
- this.nazwisko = Console.ReadLine();
- Console.WriteLine("Podaj wiek");
- this.wiek = int.Parse(Console.ReadLine());
- }
- public override string ToString()
- {
- string znak;
- znak = string.Format("{0} {1}", nazwisko, wiek);
- return znak;
- }
- public class Student : Osoba
- {
- private string Uczelnia;
- private string Wydzial;
- private int rok;
- public string uczelnia
- {
- get { return Uczelnia; }
- set { Uczelnia = value; }
- }
- public Student(string uczelnia, int wiek, int rok, string wydzial, string nazwisko)
- {
- this.nazwisko = nazwisko;
- this.wiek = wiek;
- this.Uczelnia = uczelnia;
- this.Wydzial = wydzial;
- this.rok = rok;
- }
- new public void Wypisz()
- {
- Console.WriteLine("Dane studenta");
- Console.WriteLine("Podaj uczelnie");
- this.Uczelnia = Console.ReadLine();
- Console.WriteLine("Podaj Wydzial");
- this.Wydzial = Console.ReadLine();
- Console.WriteLine("Podaj rok");
- this.rok = int.Parse(Console.ReadLine());
- Console.WriteLine("Podaj nazwisko");
- this.nazwisko = Console.ReadLine();
- Console.WriteLine("Podaj wiek");
- this.wiek = int.Parse(Console.ReadLine());
- Console.WriteLine(Uczelnia, Wydzial, rok, nazwisko, wiek);
- }
- }
- static void Main(string[] args)
- {
- Osoba o1 = new Osoba("Example", 1);
- Console.WriteLine(o1);
- Student s1 = new Student("Politechnika", 2, 3, "Poli", "Cos");
- s1.Wypisz();
- Console.WriteLine(s1);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement