22 public int getFace() {
23 return this.face;
24 }
25 public String toString() {26 String output = "";27 //add switch case that sets output to the face of the card28 switch(this.getFace()) {29 case 1:30 output = "Ace";31 break; 32 case 11:33 output = "Jack";34 break;35 case 12:36 output = "Queen";37 break;38 case 13:39 output = "King";40 break;41 default:42 output = Integer.toString(this.getFace());43 }44 //add another switch case that adds " of " and the suit of the card45 switch(this.getSuit()){46 case 1:47 output += " of Spades";48 break;49 case 2:50 output += " of Hearts";51 break;52 case 3:53 output += " of Diamonds";54 break;55 case 4:56 output += " of Clubs";57 break;58 }5960 return output;61 }62}
203 }
204 }
205 }
206 private static void clearHands() {207 for(Player p : players){208 p.clearHand();209 }210 dealer.clearHand();211 }212}
178 System.out.println(card);
179 }
180 }
181 private static void calculateWinner() {182 if(dealer.getHandAmount(card) > 21){183 for(Player p : players){184 if(p.getHandAmount(card) > 21){185 // tie186 } else {187 // player wins188 System.out.println(p.getName() + " wins");189190 }191 }192 } else {193 for(Player p : players){194 if(p.getHandAmount(card) > 21){195 // dealer wins196 } else if(p.getHandAmount(card) > dealer.getHandAmount(card)){197 // player wins198 } else if(p.getHandAmount(card) < dealer.getHandAmount(card)){199 // dealer wins200 } else {201 // tie202 }203 }204 }205 }206 private static void clearHands() {
207 for(Player p : players){
208 p.clearHand();
173 p.clearHand();
174 }
175 }
176 private static void printDealerHand() {177 for(Card card: dealer.getHand()){178 System.out.println(card);179 }180 }181 private static void calculateWinner() {
182 if(dealer.getHandAmount(card) > 21){
183 for(Player p : players){
136 }
137 } while(!result.equals("stand"));
138 }
139 private static void dealerTurn() {140 String result = "";141 int cardAmount = dealer.getHandAmount(card);142 do {143 if(cardAmount < 17){144 dealer.addCard(deck.dealTopCard());145 printDealerHand();146 cardAmount = dealer.getHandAmount(card);147 } else if(cardAmount > 21){148 System.out.println("Dealer busts");149 result = "stand";150 } else if(cardAmount == 21){151 System.out.println("Dealer has 21");152 result = "stand";153 } else {154 result = "stand";155 }156 if (result.equals("stand")) {157 calculateWinner();158 System.out.println("Dealer hits");159 }160 } while(!result.equals("stand"));161 }162
163 // TODO: write double down
164 private static void doubleDown(Player p) {
This method does not have any documentation.
Consider adding a documentation comment to explain its use.
While it may seem like the usage of a method is perfectly obvious, any consumers of your API may not be able to pick up on certain details.
This method appears to return an address string based on its name and the return type, but it is hard to say anything further about it. We neither know if the address will be formatted in a special way nor are we given any useful information regarding the returned value.
String getAddress() {
// ...
}
Provide a detailed description of what the method does.
/**
* Returns the address in 3 line format,
* with street address on line 1, area/city on line 2
* and state and country as well as postal code on line 3.
*/
String getAddress() {
// ...
}