Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Program
- {
- static void Main ( string [] args )
- {
- Avatar [] avs = new Avatar [5] {new Avatar(), new Avatar (), new Avatar (), new Avatar (), new Avatar () };
- avs [0].Name = "Roma";
- avs [1].Name = "Vasiliy";
- avs [2].Name = "Pavel";
- avs [3].Name = "Anton";
- avs [4].Name = "Max";
- Console.WriteLine ("У вас есть {0} аватаров\n", avs.Length);
- Console.WriteLine ("Их имена:");
- foreach ( Avatar avatar in avs )
- {
- avatar.Hunger = 100;
- Console.WriteLine (avatar.Name);
- }
- Console.WriteLine ("Напишите имя того, кого вы хотите покормить");
- switch ( Console.ReadLine() )
- {
- case "Roma":
- Feed ( avs [0], 10 );
- Console.WriteLine ( "Голод равен "+avs [0].Hunger);
- break;
- case "Vasiliy":
- Feed ( avs [1], 10 );
- Console.WriteLine ( "Голод равен " + avs [1].Hunger );
- break;
- case "Pavel":
- Feed ( avs [2], 10 );
- Console.WriteLine ( "Голод равен " + avs [2].Hunger );
- break;
- case "Anton":
- Feed ( avs [3], 10 );
- Console.WriteLine ( "Голод равен " + avs [3].Hunger );
- break;
- case "Max":
- Feed ( avs [4], 10 );
- Console.WriteLine ( "Голод равен " + avs [4].Hunger );
- break;
- default:
- Console.WriteLine ("Нельзя покормить того, кого нет");
- break;
- }
- }
- static void Feed ( Avatar avatar, int foodCount )
- {
- avatar.Hunger -= foodCount;
- avatar.Fatigue += foodCount / 4;
- }
- }
- class Avatar
- {
- public int Money, Fatigue, Hunger;
- public string Name;
- }
Advertisement
Add Comment
Please, Sign In to add comment