kisame1313

Untitled

Jul 21st, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.63 KB | None | 0 0
  1. using System;
  2.  
  3. class Program
  4. {
  5.     static void Main ( string [] args )
  6.     {
  7.         Avatar [] avs = new Avatar [5] {new Avatar(), new Avatar (), new Avatar (), new Avatar (), new Avatar () };
  8.  
  9.         avs [0].Name = "Roma";
  10.         avs [1].Name = "Vasiliy";
  11.         avs [2].Name = "Pavel";
  12.         avs [3].Name = "Anton";
  13.         avs [4].Name = "Max";
  14.  
  15.         Console.WriteLine ("У вас есть {0} аватаров\n", avs.Length);
  16.         Console.WriteLine ("Их имена:");
  17.         foreach ( Avatar avatar in avs )
  18.         {
  19.  
  20.             avatar.Hunger = 100;
  21.             Console.WriteLine (avatar.Name);
  22.         }
  23.         Console.WriteLine ("Напишите имя того, кого вы хотите покормить");
  24.         switch ( Console.ReadLine() )
  25.         {
  26.             case "Roma":
  27.                 Feed ( avs [0], 10 );
  28.                 Console.WriteLine ( "Голод равен "+avs [0].Hunger);
  29.                 break;
  30.             case "Vasiliy":
  31.                 Feed ( avs [1], 10 );
  32.                 Console.WriteLine ( "Голод равен " + avs [1].Hunger );
  33.                 break;
  34.             case "Pavel":
  35.                 Feed ( avs [2], 10 );
  36.                 Console.WriteLine ( "Голод равен " + avs [2].Hunger );
  37.                 break;
  38.             case "Anton":
  39.                 Feed ( avs [3], 10 );
  40.                 Console.WriteLine ( "Голод равен " + avs [3].Hunger );
  41.                 break;
  42.             case "Max":
  43.                 Feed ( avs [4], 10 );
  44.                 Console.WriteLine ( "Голод равен " + avs [4].Hunger );
  45.                 break;
  46.             default:
  47.                 Console.WriteLine ("Нельзя покормить того, кого нет");
  48.                 break;
  49.         }
  50.     }
  51.  
  52.     static void Feed ( Avatar avatar, int foodCount )
  53.     {
  54.         avatar.Hunger -= foodCount;
  55.         avatar.Fatigue += foodCount / 4;
  56.     }
  57. }
  58.  
  59. class Avatar
  60. {
  61.     public int Money, Fatigue, Hunger;
  62.     public string Name;
  63. }
Advertisement
Add Comment
Please, Sign In to add comment