Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace console
- {
- class Animal
- {
- public string Type{get;}
- public string Family { get; }
- public string Fell { get;}
- public int Legs { get; }
- public bool Tail { get;}
- public int Weight { get; }
- public int Height { get; }
- public string Food { get; }
- public Animal(string type, string family, string fell, int legs, bool tail, int weight,int height, string food)
- {
- if (string.IsNullOrWhiteSpace(type))
- {
- throw new ArgumentNullException(nameof(type));
- }
- if (string.IsNullOrWhiteSpace(family))
- {
- throw new ArgumentNullException(nameof(family));
- }
- if (string.IsNullOrWhiteSpace(fell))
- {
- throw new ArgumentNullException(nameof(fell));
- }
- if (string.IsNullOrWhiteSpace(food))
- {
- throw new ArgumentNullException(nameof(food));
- }
- if (legs < 0)
- {
- throw new ArgumentException(nameof(legs));
- }
- if (height <= 0)
- {
- throw new ArgumentException(nameof(height));
- }
- if (weight <= 0)
- {
- throw new ArgumentException(nameof(weight));
- }
- }
- public override string ToString()
- {
- return $"Вид:{Type}, Порода: {Family}, Шерсть: {Fell}, Количество лап: {Legs}, Наличие хвоста: {Tail}, Вес: {Weight}, Рост: {Height}, Рацион: {Food}";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement