-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathGroup.cs
More file actions
40 lines (36 loc) · 677 Bytes
/
Group.cs
File metadata and controls
40 lines (36 loc) · 677 Bytes
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
using System.Collections.Generic;
namespace SoftwarePatterns.Core.Composite
{
public class Group : IParty
{
public Group()
{
Members = new List<IParty>();
}
public string Name { get; set; }
public List<IParty> Members { get; set; }
public int Gold
{
get
{
var totalGold = 0;
Members.ForEach(person => totalGold += person.Gold);
return totalGold;
}
set
{
var split = value / Members.Count;
var leftOver = value % Members.Count;
Members.ForEach(person =>
{
person.Gold = split + leftOver;
leftOver = 0;
});
}
}
public void Stats()
{
Members.ForEach(person => person.Stats());
}
}
}