From 9c5a50d74a71a57f3001df002053d70c945554d0 Mon Sep 17 00:00:00 2001 From: Tobydrama Date: Thu, 12 Mar 2020 11:24:04 +0100 Subject: [PATCH] Added more comments to deck --- .../inf112/fiasko/roborally/objects/Deck.java | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/main/java/inf112/fiasko/roborally/objects/Deck.java b/src/main/java/inf112/fiasko/roborally/objects/Deck.java index 9988b04..4d0b8dc 100644 --- a/src/main/java/inf112/fiasko/roborally/objects/Deck.java +++ b/src/main/java/inf112/fiasko/roborally/objects/Deck.java @@ -18,6 +18,9 @@ public abstract class Deck implements IDeck { this.cardList = new ArrayList<>(cardList); } + /** + * Randomises the order of the deck + */ @Override public void shuffle() { Random randomGenerator = new Random(); @@ -31,12 +34,21 @@ public abstract class Deck implements IDeck { } } + /** + * Draws one card from the other deck + * @param other The deck to draw the card from + */ @Override public void draw(IDeck other) { Deck otherDeck = (Deck) other; cardList.add(otherDeck.cardList.remove(0)); } + /** + * Draws multiple cards from the other deck + * @param other The other deck to draw from + * @param n The number of cards to draw + */ @Override public void draw(IDeck other, int n) { Deck otherDeck = (Deck) other; @@ -48,27 +60,47 @@ public abstract class Deck implements IDeck { } } + /** + * Empty the entire deck into the other deck + * @param other The deck to move this deck's cards into + */ @Override public void emptyInto(IDeck other) { Deck otherDeck = (Deck) other; otherDeck.draw(this, this.size()); } + /** + * Checks if the deck is empty + * @return Boolean for if the deck is empty + */ @Override public boolean isEmpty() { return cardList.isEmpty(); } + /** + * Gets the size of the deck + * @return int size of the deck + */ @Override public int size() { return cardList.size(); } + /** + * Gets a list of all the cards in the deck + * @return ArrayList of cards from the deck + */ @Override public List getCards() { return new ArrayList<>(cardList); } + /** + * Gets the card from the deck in String format + * @return String the cards from the deck + */ @Override public String toString() { StringBuilder builder = new StringBuilder(); @@ -78,11 +110,19 @@ public abstract class Deck implements IDeck { return builder.toString(); } + /** + * Looks at the top card in the deck + * @return ProgrammingCard the first card in the deck + */ @Override public T peekTop() { return cardList.get(0); } + /** + * Looks at the bottom card of the deck + * @return ProgrammingCard the last card in the deck + */ @Override public T peekBottom() { return cardList.get(size()-1);