Advertisement
NecrogeniC

Untitled

Mar 31st, 2015
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.84 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApplication9
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Strelci prvni = new Strelci();
  14.             Strelci druhy = new Strelci();
  15.             Console.WriteLine("Zadej jmeno prvniho strelce");
  16.             prvni.jmeno = Console.ReadLine();
  17.             Console.WriteLine("Zadej jmeno druheho strelce");
  18.             druhy.jmeno = Console.ReadLine();
  19.             Console.WriteLine(prvni.GetInfo());
  20.             Console.WriteLine(druhy.GetInfo());
  21.             while (prvni.zivoty > 0 && druhy.zivoty > 0)
  22.             {
  23.                 Random a = new Random(5); //magické číslo
  24.                 int cisloA = a.Next(0, 3);
  25.             prvni.Vystrel(druhy, cisloA);
  26.                 Random b = new Random(55);// magické číslo
  27.                 int cisloB = b.Next(0, 3);
  28.             druhy.Vystrel(prvni, cisloB);
  29.             Console.WriteLine(prvni.GetInfo());
  30.             Console.WriteLine(druhy.GetInfo());
  31.            
  32.             Console.ReadLine();
  33.             }
  34.             Console.WriteLine();
  35.            
  36.             Console.ReadLine();
  37.  
  38.         }
  39.     }
  40. }
  41.  
  42. class Strelci
  43. {
  44.     public string jmeno;
  45.     public int zivoty = 10;
  46.     public int armor = 1;
  47.  
  48.     public void Vystrel(Strelci protihrac, int a)
  49.     {
  50.         int Odecet = a - armor;
  51.         if (Odecet < 0)
  52.         {
  53.             Odecet = 0;
  54.         }
  55.         Console.WriteLine("Práásk!!! Hráč " + jmeno + " vystřelil na " + protihrac.jmeno + " a způsobil " + a + " poškození");
  56.         protihrac.zivoty = protihrac.zivoty - Odecet;
  57.  
  58.  
  59.     }
  60.  
  61.     public string GetInfo()
  62.     {
  63.         string info = jmeno + " má " + zivoty + " životů";
  64.         return info;
  65.     }
  66.  
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement