private void assignCards() { player.clearCards(); dealer.clearCards(); for (int i = 0; i < 3; ++i) { player.assignCard(genNewCard()); dealer.assignCard(genNewCard()); } }
private void judge() { if (player.numOfSpecialCards() > dealer.numOfSpecialCards()) { player.win(); dealer.lose(); } else if (player.numOfSpecialCards() < dealer.numOfSpecialCards()) { dealer.win(); player.lose(); } else { int playerScore = 0, dealerScore = 0; for (Card card : player.getCards()) { if (!card.isSpecial()) playerScore += card.getValue(); playerScore %= 10; } for (Card card : dealer.getCards()) { if (!card.isSpecial()) dealerScore += card.getValue(); dealerScore %= 10; } if (playerScore > dealerScore) { player.win(); dealer.lose(); } else { dealer.win(); player.lose(); } } }
/** * Update changing components. * * @see javax.swing.JComponent#paintComponent(java.awt.Graphics) */ @Override public void paintComponent(Graphics g) { money.setText(String.valueOf(player.getMoney())); record.setText(String.valueOf(bestScore)); dealerPanel.removeAll(); playerPanel.removeAll(); for (Card dealerCard : dealer.getCards()) dealerPanel.add(dealerCard); for (Card playerCard : player.getCards()) playerPanel.add(playerCard); revalidate(); }
@Property(name = PROPERTY_DEALER) public boolean setDealer(Dealer value) { boolean changed = false; if (this.dealer != value) { Dealer oldValue = this.dealer; Player source = this; if (this.dealer != null) { this.dealer = null; oldValue.setPlayer(null); } this.dealer = value; if (value != null) { value.setPlayer(this); } changed = true; } return changed; }
public void RegisterSubscribers(IObserver a_observer) { m_dealer.Register(a_observer); }
public int GetDealerScore() { return m_dealer.CalcScore(); }
public Iterable<Card> GetDealerHand() { return m_dealer.GetHand(); }
public boolean Stand() { return m_dealer.Stand(m_player); }
public boolean Hit() { return m_dealer.Hit(m_player); }
public boolean NewGame() { return m_dealer.NewGame(m_player); }
public boolean IsDealerWinner() { return m_dealer.IsDealerWinner(m_player); }
public boolean IsGameOver() { return m_dealer.IsGameOver(); }
public void onClick(View v) { dealer.setRoom(room_no.getText().toString()); dealer.joinRoom(); closePage(); }
public boolean isGameOver(Dealer dealer, PlayerList playerList) { if (dealer.isDeckEmpty() && playerList.isAllPlayerHandEmpty()) return true; return false; }