fork(1) download
  1. using System;
  2.  
  3. public class Test
  4. {
  5. class Pet
  6. {
  7. public string Name; // имя питомца
  8. public int Legs; // количество ног питомца
  9. public string Voice; // голос питомца
  10. public static int TotalLegs; // общее количество ног питомца
  11.  
  12. public void WhoAreYou()
  13. {
  14. Console.Write("What is your pet`s name? ");
  15. Name = Console.ReadLine();
  16. Console.WriteLine(Name);
  17. Console.WriteLine("How many legs does it have? ");
  18. Legs = int.Parse(Console.ReadLine());
  19. Console.WriteLine("What does it say? ");
  20. Voice = Console.ReadLine();
  21.  
  22. TotalLegs += Legs;
  23. }
  24. }
  25.  
  26. public static void Main()
  27. {
  28. Pet myPet1 = new Pet();
  29. myPet1.WhoAreYou();
  30. Pet myPet2 = new Pet();
  31. myPet2.WhoAreYou();
  32. Pet myPet3 = new Pet();
  33. myPet3.WhoAreYou();
  34.  
  35. Console.WriteLine("They have {0} legs.", Pet.TotalLegs);
  36. }
  37. }
Success #stdin #stdout 0.03s 33880KB
stdin
Karkusha
2
Karrr!
Barsik
4
may
Kesha
2
Kesha good

stdout
What is your pet`s name? Karkusha
How many legs does it have? 
What does it say? 
What is your pet`s name? Barsik
How many legs does it have? 
What does it say? 
What is your pet`s name? Kesha
How many legs does it have? 
What does it say? 
They have 8 legs.