Advertisement
TArtem

fgdfg

Feb 26th, 2021
595
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 7.08 KB | None | 0 0
  1. using System;
  2.  
  3. namespace lab6
  4. {
  5.     struct Smth
  6.     {
  7.         public string name;
  8.         public int age;
  9.         public string smth;
  10.         public enum Month
  11.         {
  12.             January = 1,
  13.             February,
  14.             March,
  15.             April,
  16.             May,
  17.             June,
  18.             July,
  19.             August,
  20.             September,
  21.             October,
  22.             November,
  23.             December
  24.         }
  25.     }
  26.  
  27.     public partial class Lion : Mammals, IAnimal
  28.     {
  29.         public Lion(){}
  30.         public Lion(int pos, int yob, bool isPred)
  31.         {
  32.             position = pos;
  33.             YearOfBirth = yob;
  34.             IsPredator = isPred;
  35.         }
  36.         public override void eat()
  37.         {
  38.             Console.WriteLine("Lion drinks milk.");
  39.         }
  40.  
  41.         public override void sleep()
  42.         {
  43.             Console.WriteLine($"Lion sleeps.");
  44.         }
  45.  
  46.         public void hunt()
  47.         {
  48.             Console.WriteLine("Hunt in progress...");
  49.             System.Threading.Thread.Sleep(1000);
  50.             Console.WriteLine("Hunt complete!");
  51.         }
  52.  
  53.         public override string ToString()
  54.         {
  55.             return @$"Info:
  56.                    Position: {position}
  57.                    Date of birth: {YearOfBirth}
  58.                    Object type: Lion";
  59.         }
  60.     }
  61.  
  62.     public class Tiger : Mammals, IAnimal
  63.     {
  64.         public Tiger() { }
  65.         public Tiger(int pos, int yob, bool isPred)
  66.         {
  67.             position = pos;
  68.             YearOfBirth = yob;
  69.             IsPredator = isPred;
  70.         }
  71.         public override void eat()
  72.         {
  73.             Console.WriteLine("Tiger drinks milk.");
  74.         }
  75.  
  76.         public override int move()
  77.         {
  78.             position += 1;
  79.             Console.WriteLine($"Tiger moved to {position}.");
  80.             return position;
  81.         }
  82.  
  83.         public override void sleep()
  84.         {
  85.             Console.WriteLine($"Tiger sleeps.");
  86.         }
  87.  
  88.         public void hunt()
  89.         {
  90.             Console.WriteLine("Hunt in progress...");
  91.             System.Threading.Thread.Sleep(1000); //наохотился и спит
  92.             Console.WriteLine("Hunt complete!");
  93.         }
  94.  
  95.         public override string ToString()
  96.         {
  97.             return @$"Info:
  98.                    Position: {position}
  99.                    Date of birth: {YearOfBirth}
  100.                    Object type: Tiger";
  101.         }
  102.     }
  103.  
  104.     public class Owl : Bird, IAnimal
  105.     {
  106.         public Owl() { }
  107.         public override void eat()
  108.         {
  109.             Console.WriteLine("Owl eats insects.");
  110.         }
  111.  
  112.         public override int move()
  113.         {
  114.             position += 1;
  115.             Console.WriteLine($"Owl moved to {position}.");
  116.             return position;
  117.         }
  118.  
  119.         public override void sleep()
  120.         {
  121.             Console.WriteLine($"OWL'S WATCHIN YA.");
  122.         }
  123.  
  124.         public void hunt()
  125.         {
  126.             Console.WriteLine("Hunt in progress...");
  127.             System.Threading.Thread.Sleep(1000); //наохотился и спит
  128.             Console.WriteLine("Hunt complete!");
  129.         }
  130.  
  131.         public override string ToString()
  132.         {
  133.             return @$"Info:
  134.                    Position: {position}
  135.                    Date of birth: {YearOfBirth}
  136.                    Predator: {IsPredator}
  137.                    Object type: Owl";
  138.         }
  139.     }
  140.  
  141.     public class Croc : IAnimal
  142.     {
  143.         int position;
  144.         public Croc() { }
  145.         public void eat()
  146.         {
  147.             Console.WriteLine("Owl eats insects.");
  148.         }
  149.  
  150.         public int move()
  151.         {
  152.             position += 1;
  153.             Console.WriteLine($"Owl moved to {position}.");
  154.             return position;
  155.         }
  156.  
  157.         public void sleep()
  158.         {
  159.             Console.WriteLine($"OWL'S WATCHIN YA.");
  160.         }
  161.  
  162.         public void hunt()
  163.         {
  164.             Console.WriteLine("Hunt in progress...");
  165.             System.Threading.Thread.Sleep(1000); //наохотился и спит
  166.             Console.WriteLine("Hunt complete!");
  167.         }
  168.  
  169.         public void a_method()
  170.         {
  171.             Console.WriteLine("a_method worked.");
  172.         }
  173.     }
  174.  
  175.     public class Shark : Fish
  176.     {
  177.         public Shark() { }
  178.         public override void eat()
  179.         {
  180.             Console.WriteLine("Shark eats fish.");
  181.         }
  182.  
  183.         public override int move()
  184.         {
  185.             position += 1;
  186.             Console.WriteLine($"Shark moved to {position}.");
  187.             return position;
  188.         }
  189.  
  190.         public override void sleep()
  191.         {
  192.             Console.WriteLine($"Shark sleeps.");
  193.         }
  194.  
  195.         public void hunt()
  196.         {
  197.             Console.WriteLine("Hunt in progress...");
  198.             System.Threading.Thread.Sleep(1000); //наохотился и спит
  199.             Console.WriteLine("Hunt complete!");
  200.         }
  201.     }
  202.  
  203.     public sealed class Parrot : Bird
  204.     {
  205.         public Parrot() { }
  206.         public override void eat()
  207.         {
  208.             Console.WriteLine("Parrot eat breadcrumbs and drink water.");
  209.         }
  210.  
  211.         public override int move()
  212.         {
  213.             position += 1;
  214.             Console.WriteLine($"Parrot flies to {position}.");
  215.             return position;
  216.         }
  217.  
  218.         public override void sleep()
  219.         {
  220.             Console.WriteLine($"Parrot sleeps.");
  221.         }
  222.  
  223.         public void hunt()
  224.         {
  225.             Console.WriteLine("Hunt in progress...");
  226.             System.Threading.Thread.Sleep(1000); //наохотился и спит
  227.             Console.WriteLine("Hunt complete!");
  228.         }
  229.  
  230.         public override string ToString()
  231.         {
  232.             return @$"Info:
  233.                    Position: {position}
  234.                    Date of birth: {YearOfBirth}
  235.                    Predator: {IsPredator}
  236.                    Object type: Parrot";
  237.         }
  238.     }
  239.  
  240.     public class NewClass : Animal, IAnimal
  241.     {
  242.         public NewClass() { }
  243.         public override void eat()
  244.         {
  245.             Console.WriteLine("Parrot eat breadcrumbs and drink water.");
  246.         }
  247.  
  248.         public override int move()
  249.         {
  250.             position += 1;
  251.             Console.WriteLine($"Parrot flies to {position}.");
  252.             return position;
  253.         }
  254.  
  255.         public override void sleep()
  256.         {
  257.             Console.WriteLine($"Parrot sleeps.");
  258.         }
  259.  
  260.         public void hunt()
  261.         {
  262.             Console.WriteLine("Hunt in progress...");
  263.             System.Threading.Thread.Sleep(1000); //наохотился и спит
  264.             Console.WriteLine("Hunt complete!");
  265.         }
  266.  
  267.         void IAnimal.a_method()
  268.         {
  269.             Console.WriteLine("Ianimal.a_method worked.");
  270.         }
  271.  
  272.         public override void a_method()
  273.         {
  274.             Console.WriteLine("Animal.a_method worked.");
  275.  
  276.         }
  277.     }
  278.  
  279.     public class Print
  280.     {
  281.         public void IAmPrinting(Animal obj)
  282.         {
  283.             Console.WriteLine(obj.ToString());
  284.         }
  285.     }
  286. }
  287.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement