Advertisement
Guest User

dog

a guest
Dec 25th, 2019
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.52 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4.  
  5. namespace console
  6. {
  7.     class Dog : Animal
  8.     {
  9.  
  10.         public Dog(string type, string family, string fell, int legs, bool tail, int weight, int height, string food) : base(type, family, fell, legs, tail,weight,height, food)
  11.         {
  12.  
  13.         }
  14.  
  15.         public static Dog operator *(Dog dog1, Dog dog2)
  16.         {
  17.             Random rnd = new Random();
  18.  
  19.             int key = rnd.Next(0, 1);
  20.             string type, family, fell, food;
  21.             int legs, weight, height;
  22.             bool tail;
  23.  
  24.             if (key == 0) { type = dog1.Type; }
  25.             else { type = dog2.Type; }
  26.  
  27.             key = rnd.Next(0, 1);
  28.             if (key == 0) {  family = dog1.Family; }
  29.             else {  family = dog2.Family; }
  30.  
  31.             key = rnd.Next(0, 1);
  32.             if (key == 0) { fell = dog1.Fell; }
  33.             else { fell = dog2.Fell; }
  34.  
  35.             legs = dog1.Legs;
  36.  
  37.             key = rnd.Next(0, 1);
  38.             if (dog1.Tail == dog2.Tail) { tail = dog1.Tail; }
  39.             else if (key == 0) { tail = dog1.Tail; }
  40.             else { tail = dog2.Tail; }
  41.  
  42.             weight = (int)((dog1.Weight + dog2.Weight) / 2);
  43.             height = (int)((dog1.Height + dog2.Height) / 2);
  44.  
  45.             key = rnd.Next(0, 1);
  46.             if (key == 0) { food = dog1.Food; }
  47.             else { food = dog2.Food; }
  48.  
  49.             var dog = new Dog(type, family, fell, legs, tail, weight, height, food);
  50.  
  51.             return dog;
  52.         }
  53.     }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement