x86Cow / javaBlackjack

Undocumented method found JAVA-D1001
Documentation
Minor
a year agoa year old
Consider adding a doc comment for toString
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}
Consider adding a doc comment for clearHands
203            }
204        }
205    }
206    private static void clearHands() {207        for(Player p : players){208            p.clearHand();209        }210        dealer.clearHand();211    }212}
Consider adding a doc comment for calculateWinner
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();
Consider adding a doc comment for printDealerHand
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){
Consider adding a doc comment for dealerTurn
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) {