-
Notifications
You must be signed in to change notification settings - Fork 0
/
Player.cs
61 lines (58 loc) · 1.32 KB
/
Player.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
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Player
{
public Player(String n)
{
name = n;
playPile = new Pile();
wonPile = new Pile();
Score = 0;
}
public Card playCard()
{
if (playPile.getSize() == 0) useWonPile();
if (playPile.getSize() > 0)
return playPile.nextCard();
return null;
}
public String getName()
{
return name;
}
public void collectCard(Card c)
{
wonPile.addCard(c);
}
public void collectCards(Pile p)
{
wonPile.addCards(p);
}
public void useWonPile()
{
playPile.clear();
playPile.addCards(wonPile);
wonPile.clear();
}
public int numCards()
{
return playPile.getSize() + wonPile.getSize();
}
public void KeepCard()
{
this.Score++;
}
public int getscore()
{
return this.Score;
}
private Pile playPile, wonPile;
private String name;
private int Score;
}
}