Advertisement
Alk_136

Untitled

Jul 14th, 2016
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.54 KB | None | 0 0
  1. #region туман
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8. namespace homework
  9. {
  10.     #endregion
  11.     class Program
  12.     {
  13.         static bool life = true;
  14.         static string name;
  15.  
  16.         static void Main(string[] args)
  17.         {
  18.             Console.WriteLine("Введите имя ");
  19.             name = Console.ReadLine();
  20.             Console.WriteLine("Введите возраст " + name);
  21.             byte old = Convert.ToByte(Console.ReadLine());
  22.             sbyte health = 100;
  23.             while ( life ==true )
  24.            
  25.                 health = damage(old,health);
  26.            
  27.  
  28.             Console.ReadLine();
  29.         }
  30.         static sbyte damage(byte old,sbyte health)
  31.         {
  32.             Console.WriteLine("Введите количество урона ");
  33.             byte Damage = Convert.ToByte(Console.ReadLine());
  34.             if (health > Damage)
  35.             {
  36.                 health = Convert.ToSByte(health - Damage);
  37.                 Console.Clear();
  38.                 Console.Write("Имя: " + name);
  39.                 Console.WriteLine("; здовье- " + health + "; возраст " + name + " -" + old + ".");
  40.  
  41.                 return health;
  42.             }
  43.             else
  44.             {
  45.                 health = 0;
  46.                 life = false;
  47.                 Console.WriteLine(name + " умер!");
  48.                 name = "deathUser";
  49.                 return health;
  50.                
  51.             }
  52.         }
  53.     }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement