package edu.ew.model;

import java.util.Collections;
import java.util.Iterator;
import java.util.Observable;
import java.util.Stack;

/**
 * Represents a pile cards.
 * 
 * @author Selcuk Gulcan
 *
 */
public class CardPile extends Observable{

	protected Stack<Card> cards;
	
	public CardPile() {
		
		cards = new Stack<Card>();
	}
	
	public void shuffle() {
		
		Collections.shuffle( cards);
		setChanged();
		notifyObservers();
	}
	
	public Card draw() {
		
		Card card = cards.pop();
		setChanged();
		notifyObservers();
		return card;
	}
	
	public void add( Card card) {
		
		cards.push( card);
		setChanged();
		notifyObservers();
	}
	
	public void remove( Card card) {
		
		cards.remove( card);
		setChanged();
		notifyObservers();
	}
	
	public Iterator<Card> iterator() {
		
		return cards.iterator();
	}
	
	public int getNoOfCards() {
		
		return cards.size();
	}
	
	//TRIVIAL METHODS
	public Stack<Card> getCards() {
		return cards;
	}

	public void setCards(Stack<Card> cards) {
		this.cards = cards;
	}
}

@@ -192,11 +192,64 @@
 can%0A
+ * @author Serdar Demirkol%0A * @author Umut Hicyilmaz%0A
  *%0A
-
  */%0A
@@ -323,16 +323,56 @@
 ards;%0A%09%0A
+%09/**%0A%09 * Constructor for cardPiles%0A%09 */%0A
 %09public 
@@ -413,32 +413,65 @@
 k%3CCard%3E();%0A%09%7D%0A%09%0A
+%09/**%0A%09 * Shuffles the cards%0A%09 */%0A
 %09public void shu
@@ -547,32 +547,58 @@
 servers();%0A%09%7D%0A%09%0A
+%09/**%0A%09 * Draws cards%0A%09 */%0A
 %09public Card dra
@@ -686,24 +686,78 @@
  card;%0A%09%7D%0A%09%0A
+%09/**%0A%09 * Adds cards to pile%0A%09 * %0A%09 * @param card%0A%09 */%0A
 %09public void
@@ -833,32 +833,91 @@
 servers();%0A%09%7D%0A%09%0A
+%09/**%0A%09 * Removes cards from pile%0A%09 * %0A%09 * @param card%0A%09 */%0A
 %09public void rem
@@ -994,32 +994,76 @@
 servers();%0A%09%7D%0A%09%0A
+%09/**%0A%09 * Iterates through the cardPile%0A%09 */%0A
 %09public Iterator
@@ -1117,16 +1117,86 @@
 );%0A%09%7D%0A%09%0A
+%09/**%0A%09 * Gets number of cards in Pile%0A%09 * %0A%09 * @return NoOfCards%0A%09 */%0A
 %09public 
@@ -1266,16 +1266,64 @@
 METHODS%0A
+%09/**%0A%09 * Gets cards%0A%09 * %0A%09 * @return cards%0A%09 */%0A
 %09public 
@@ -1366,16 +1366,64 @@
 rds;%0A%09%7D%0A
+%09%0A%09/**%0A%09 * Sets cards%0A%09 * %0A%09 * @param cards%0A%09 */
 %0A%09public

Update CardPile.java