Advertisement
Guest User

Untitled

a guest
Apr 5th, 2020
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.29 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 Lab01
  8. {
  9.     public abstract class Osoba
  10.     {
  11.         protected string Name;
  12.         public Osoba()
  13.         {
  14.             Console.WriteLine("Utworzono objekt klasy 'Osoba'");
  15.             Name = "unknown";
  16.         }
  17.         public Osoba(string name)
  18.         {
  19.             Console.WriteLine("Utworzono objekt klasy 'Osoba' i zainicjowano pole 'Name'");
  20.             Name = name;
  21.         }
  22.         public String GetName()
  23.         {
  24.             return Name;
  25.         }
  26.         public void Je(string jedzenie)
  27.         {
  28.  
  29.         }
  30.         public void Ubiera(string ubranie)
  31.         {
  32.  
  33.         }
  34.  
  35.     }
  36.  
  37.  
  38.     public class Ojciec : Osoba
  39.     {
  40.        public Ojciec(string name) : base(name)
  41.         {
  42.  
  43.         }
  44.     }
  45.  
  46.  
  47.     public class Syn : Osoba
  48.     {
  49.         public Syn(string name) : base(name)
  50.         {
  51.            
  52.         }
  53.     }
  54.  
  55.  
  56.     class Program
  57.     {
  58.         static void Main(string[] args)
  59.         {
  60.             Console.WriteLine("Hello");
  61.             var person1 = new Ojciec("Rafał");
  62.             var person2 = new Syn("Jakub");
  63.             String A = GetName(person1);
  64.             Console.WriteLine(A);
  65.         }
  66.     }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement