SHOW:
|
|
- or go back to the newest paste.
1 | using System; | |
2 | ||
3 | namespace C_sharp_Light | |
4 | { | |
5 | class Program | |
6 | { | |
7 | static void Main(string[] args) | |
8 | { | |
9 | - | |
9 | + | Player player = new Player("Alexander", 20, 5); |
10 | player.ShowInfo(); | |
11 | Console.ReadKey(); | |
12 | } | |
13 | } | |
14 | ||
15 | ||
16 | class Player | |
17 | { | |
18 | public string Name { get; private set; } | |
19 | public int HealthBase { get; private set; } | |
20 | public int DamageBase { get; private set; } | |
21 | private Characteristics _characteristics; | |
22 | ||
23 | public Player(string name, int healthBase, int damageBase) | |
24 | { | |
25 | Name = name; | |
26 | HealthBase = healthBase; | |
27 | DamageBase = damageBase; | |
28 | _characteristics = new Characteristics(); | |
29 | } | |
30 | ||
31 | public void ShowInfo() | |
32 | { | |
33 | Console.WriteLine($"Воина зовут {Name}. Базовое хп = {HealthBase}, Базовый дамаг = {DamageBase}.\n" + | |
34 | $"Сила - {_characteristics.Power}; Ловкость - {_characteristics.Agility}; Ум - {_characteristics.Mind}; Скрытность - {_characteristics.Stealth}"); | |
35 | } | |
36 | } | |
37 | ||
38 | class Characteristics | |
39 | { | |
40 | public int Power { get; private set; } | |
41 | public int Agility { get; private set; } | |
42 | public int Mind { get; private set; } | |
43 | public int Stealth { get; private set; } | |
44 | ||
45 | public Characteristics() | |
46 | { | |
47 | Power = RandomStatic.GetNext(1, 11); | |
48 | Agility = RandomStatic.GetNext(1, 11); | |
49 | Mind = RandomStatic.GetNext(1, 11); | |
50 | Stealth = RandomStatic.GetNext(1, 11); | |
51 | } | |
52 | } | |
53 | ||
54 | static class RandomStatic | |
55 | { | |
56 | static private Random _rand = new Random(); | |
57 | ||
58 | static public int GetNext(int min, int max) | |
59 | { | |
60 | return _rand.Next(min, max); | |
61 | } | |
62 | static public int GetNext(int min) | |
63 | { | |
64 | return _rand.Next(min); | |
65 | } | |
66 | } | |
67 | } |