Cassimus

zwierzęta

Sep 27th, 2025
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.58 KB | None | 0 0
  1. // Klasa zwierząt
  2. // Kury
  3. // Krowy
  4.  
  5. public abstract class Animal
  6. {
  7.     public virtual void Eat()
  8.     {
  9.         Console.WriteLine("Zwierze je");
  10.     }
  11.  
  12.     public abstract void TakeSound();
  13. }
  14.  
  15. public class Cow : Animal
  16. {
  17.     public override void TakeSound()
  18.     {
  19.         System.Console.WriteLine("Krowa robi muuu");
  20.     }
  21.  
  22.     public override void Eat()
  23.     {
  24.         System.Console.WriteLine("Krowa je trawę");
  25.     }
  26. }
  27.  
  28. public class Hen: Animal
  29. {
  30.    
  31.         public override void TakeSound()
  32.     {
  33.         System.Console.WriteLine("kura robi ko ko");
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment