-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStatistics.cs
More file actions
110 lines (100 loc) · 3.05 KB
/
Statistics.cs
File metadata and controls
110 lines (100 loc) · 3.05 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DieGame2
{
internal class Statistics
{
/// <summary>
/// The times the game is played
/// </summary>
private int _times;
/// <summary>
/// A list contains points of each time the game is played
/// </summary>
private List<int> _pointsCollection;
/// <summary>
/// A list contains the winner of each time the game is played
/// </summary>
private List<string> _winners;
/// <summary>
/// Constructor
/// </summary>
public Statistics()
{
_times = 0;
_pointsCollection = new List<int>();
_winners = new List<string>();
}
/// <summary>
/// A method to update the times
/// </summary>
/// <returns>
/// the times the game is played
/// </returns>
public int UpdateTime()
{
_times++;
return _times;
}
/// <summary>
/// A method to update the points of each time the game is played
/// </summary>
/// <param name="pointsList"> the points list of each time</param>
/// <returns>
/// a list contains the points of each time
/// </returns>
public List<int> UpdatePoints (List<int> pointsList)
{
_pointsCollection.Add(pointsList[0]);
_pointsCollection.Add(pointsList[1]);
return _pointsCollection;
}
/// <summary>
/// A method to update the winners of each time the game is played
/// </summary>
/// <param name="winner"> the winner of each time </param>
/// <returns>
/// A list contains the winners of each time
/// </returns>
public List<string> UpdateWinner(string winner)
{
_winners.Add(winner);
return _winners;
}
/// <summary>
/// A method to print out the times
/// </summary>
public void ReportTimes()
{
Console.WriteLine($"The game has been played: {_times} times.");
}
/// <summary>
/// A method to print out the points of each times
/// </summary>
public void ReportPoints()
{
int j = 0;
Console.WriteLine("Time: Player 1 (Human)'s Points, Player 2 (Computer)'s Points.");
for (int i = 0; i < _times; i++)
{
Console.WriteLine($"{i+1}: {_pointsCollection[j]}, {_pointsCollection[j+1]}.");
j += 2;
}
}
/// <summary>
/// A method to print out the winner of each time
/// </summary>
public void ReportWinners()
{
Console.Write("Winners List: ");
foreach (var winner in _winners)
{
Console.Write(winner);
Console.Write(" ");
}
}
}
}