commit c6361a258cd045a5fd2afec6fd14d4d514bd5483
parent 59ba0ab93e96a12d76550603b7fcc508b6e8ad4a
Author: Michael Neuper <michael@michaelneuper.com>
Date: Mon, 1 May 2023 15:57:53 +0200
Add docs for file path functions
Diffstat:
4 files changed, 35 insertions(+), 8 deletions(-)
diff --git a/src/controller/Controller.java b/src/controller/Controller.java
@@ -276,11 +276,21 @@ public class Controller {
public String displayDealerFirstCardValue() {
return DEALER.printFirstCardValue();
}
-
+
+ /**
+ *
+ * @param i index of the card in the dealer's hand
+ * @return file path of the dealer's card
+ */
public String getDealerCardFilePath(int i) {
return DEALER.printFilePath(i);
}
-
+
+ /**
+ *
+ * @param i index of the card in the player's hand
+ * @return file path of player's card
+ */
public String getPlayerCardFilePath(int i) {
return PLAYER.printFilePath(i);
}
diff --git a/src/controller/Hand.java b/src/controller/Hand.java
@@ -71,7 +71,13 @@ public class Hand {
public Card getCard(int i) {
return HAND.get(i);
}
-
+
+ /**
+ *
+ * @param i index of the card in hand
+ * @return file path of a card at a specific index, if the index is out of
+ * range, a blank card is returned
+ */
public String getCardFilePath(int i) {
try {
return "/assets/cards/" + HAND.get(i).getFilename();
diff --git a/src/model/Card.java b/src/model/Card.java
@@ -137,7 +137,12 @@ public class Card {
public Rank getRank() {
return rank;
}
-
+
+ /**
+ * Returns a file representation of a card in the form "ace_of_spades.png"
+ *
+ * @return file representation of a card
+ */
public String getFilename() {
return rank.toString().toLowerCase() + "_of_" + suit.toString().toLowerCase() + ".png";
}
@@ -152,5 +157,5 @@ public class Card {
public String toString() {
return rank + " of " + suit;
}
-
+
}
diff --git a/src/model/Person.java b/src/model/Person.java
@@ -8,7 +8,7 @@ import controller.Hand;
* <p>
* Contains information about a person in a blackjack game, such as their name
* and hand.</p>
- *
+ *
* @see Player
* @see Dealer
*
@@ -81,7 +81,13 @@ public abstract class Person {
public String printHand() {
return this.hand + "";
}
-
+
+ /**
+ * Prints the file path of a card at a given index
+ *
+ * @param i index of the card
+ * @return file path of the card at index i
+ */
public String printFilePath(int i) {
return hand.getCardFilePath(i);
}
@@ -99,5 +105,5 @@ public abstract class Person {
}
this.hand.takeCardFromDeck(deck);
}
-
+
}