Advertisement
Guest User

Class

a guest
Dec 25th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.72 KB | None | 0 0
  1. using System;
  2.  
  3. namespace console
  4. {
  5.     class Animal
  6.     {
  7.  
  8.         public string Type{get;}
  9.  
  10.         public string Family { get; }
  11.  
  12.         public string Fell { get;}
  13.  
  14.         public int Legs { get;  }
  15.  
  16.         public bool Tail { get;}
  17.  
  18.  
  19.         public int Weight { get; }
  20.  
  21.         public int Height { get; }
  22.  
  23.         public string Food { get; }
  24.  
  25.  
  26.         public Animal(string type, string family, string fell, int legs, bool tail, int weight,int height, string food)
  27.         {
  28.  
  29.             if (string.IsNullOrWhiteSpace(type))
  30.             {
  31.                 throw new ArgumentNullException(nameof(type));
  32.             }
  33.             if (string.IsNullOrWhiteSpace(family))
  34.             {
  35.                 throw new ArgumentNullException(nameof(family));
  36.             }
  37.             if (string.IsNullOrWhiteSpace(fell))
  38.             {
  39.                 throw new ArgumentNullException(nameof(fell));
  40.             }
  41.             if (string.IsNullOrWhiteSpace(food))
  42.             {
  43.                 throw new ArgumentNullException(nameof(food));
  44.             }
  45.             if (legs < 0)
  46.             {
  47.                 throw new ArgumentException(nameof(legs));
  48.             }
  49.             if (height <= 0)
  50.             {
  51.                 throw new ArgumentException(nameof(height));
  52.             }
  53.             if (weight <= 0)
  54.             {
  55.                 throw new ArgumentException(nameof(weight));
  56.             }
  57.  
  58.         }
  59.  
  60.         public override string ToString()
  61.         {
  62.             return $"Вид:{Type}, Порода: {Family}, Шерсть: {Fell}, Количество лап: {Legs}, Наличие хвоста: {Tail}, Вес: {Weight}, Рост: {Height}, Рацион: {Food}";
  63.         }
  64.  
  65.     }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement