Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Card[] cards;
- public int Count { get; private set; }
- public void Shuffle() {
- List<Card> deck = new List<Card>();
- int i, x;
- for(i = 0; i < Count; i++)
- deck.Add(cards[i]);
- for(i = 0; i < Count; i++) {
- x = rand.Next(deck.Count);
- cards[i] = deck[x];
- deck.RemoveAt(x);
- }
- }
- public void AddOnTop(Card card) {
- cards[Count++] = card;
- }
- public void AddOnBottom(Card card) {
- for(int i = Count; i > 0; i--)
- cards[i] = cards[i - 1];
- Count++;
- cards[0] = card;
- }
- public void AddRandom(Card card) {
- int x = rand.Next(Count);
- for(int i = Count; i > x; i--)
- cards[i] = cards[i - 1];
- Count++;
- cards[x] = card;
- }
- public Card RemoveFromTop() {
- return cards[--Count];
- }
- public Card RemoveFromBotton() {
- Card r = cards[0];
- for(int i = 1; i < Count; i++)
- cards[i - 1] = cards[i];
- Count--;
- return r;
- }
- public Card RemoveRandom() {
- int x = rand.Next(Count);
- Card r = cards[x];
- for(int i = x + 1; i < Count; i++)
- cards[i - 1] = cards[i];
- Count--;
- return r;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement