Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ClassesWork
- {
- class Dog
- {
- protected int age;
- protected string host;
- protected string name;
- public int Age
- {
- get
- {
- return age;
- }
- }
- public string Host
- {
- get
- {
- return name;
- }
- }
- public string Name
- {
- get
- {
- return name;
- }
- }
- private string furColor;
- public string FurColor
- {
- get { return furColor; }
- set { furColor = value; }
- }
- private string eyeColor;
- public string EyeColor
- {
- get { return eyeColor; }
- set { eyeColor = value; }
- }
- public void IncreaseAge()
- {
- age++;
- }
- public void IncreaseAge(int inputAge)
- {
- if (inputAge > 0)
- age += inputAge;
- }
- public Dog(int age, string host, string name)
- {
- this.age = age;
- this.host = host;
- this.name = name;
- }
- public override string ToString()
- {
- return $"Хозяин: {host}, Имя: {name}, Возраст: {age}, Шерсть: {furColor}, Глаза: {eyeColor}";
- }
- }
- class Program
- {
- static string[] names = { "Jack", "Tim", "Owo" };
- static string[] furColors = { "Black", "White", "Brown" };
- static string[] eyeColors = { "Brown", "Blue", "Green" };
- static Random random = new Random();
- static void Main()
- {
- uint n;
- Console.WriteLine("Введите число: ");
- ReadData(out n);
- Dog[] dogs = new Dog[n];
- for (int i = 0; i < n; i++)
- {
- dogs[i] = new Dog(random.Next(3,16),"Marina sex mashina", names[random.Next(3)]);
- dogs[i].FurColor = furColors[random.Next(3)];
- dogs[i].EyeColor = eyeColors[random.Next(3)];
- Console.WriteLine(dogs[i]);
- }
- Console.ReadLine();
- }
- static bool Check(out uint input)
- {
- return uint.TryParse(Console.ReadLine(), out input);
- }
- static void ReadData(out uint input)
- {
- if (!Check(out input))
- {
- Console.WriteLine("Введенные данные неверны. Повторите ввод.");
- ReadData(out input);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement