-
Notifications
You must be signed in to change notification settings - Fork 0
/
ClassicGame.cs
36 lines (33 loc) · 1.19 KB
/
ClassicGame.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System;
namespace Lr_2
{
class ClassicGame : Game
{
public ClassicGame(string gameName) : base(gameName) { }
public override void PlayTheGame(GameAccount player1, GameAccount player2, int rating)
{
// check for correct rating
if (rating <= 0)
{
throw new ArgumentOutOfRangeException(nameof(rating), "Rating must be greater then zero");
}
// game simulation
Random rand = new Random();
int res = rand.Next(1, 3);
// first player wins
if (res == 1)
{
Console.WriteLine($"{player1.UserName} won the rating game!");
player1.WinGame(player2.UserName,rating ,"Classic" );
player2.LoseGame(player1.UserName, rating, "Classic");
}
// second player wins
else
{
Console.WriteLine($"{player2.UserName} won the rating game!");
player2.WinGame(player1.UserName, rating, "Classic");
player1.LoseGame(player2.UserName, rating, "Classic");
}
}
}
}