This site requires JavaScript, please enable it in your browser!
Greenfoot back
1920
1920 wrote ...

2015/3/9

Help on Blackjack dealer not working

1920 1920

2015/3/9

#
I have this code to make the dealer get extra cards only if dealerScore is less than 16, it compiles but in the actual game it does not work public void addDealerCard() { if (this.dealerScore < 16) { Card dealer = new Card(); getWorld() .addObject(dealer, x, 100); dealer.flipCard(); blackjack.setDealer(dealer.tellMeTheValue()); x = x +75; }
danpost danpost

2015/3/9

#
Are you calling the method from anywhere? That is, have you coded 'addDealerCard()' in an act method or in one of the methods ithe act method calls?
1920 1920

2015/3/9

#
yeah its here public void act() { if (canClick) { if (Greenfoot.mouseClicked(this)) { finishGame(); addDealerCard(); if (this.dealerScore <= 21 && this.dealerScore >= this.playerScore || this.playerScore > 21) { System.out.println("The dealer has won."); } else { System.out.println("You have won."); } canClick = false; Hit.canClick= false; } } }
1920 1920

2015/3/9

#
finishGame(); just flips the first card the dealer has
danpost danpost

2015/3/9

#
This code appears to be in an Actor subclass. I would think the general running of the hands should be done in your World subclass.
1920 1920

2015/3/10

#
It is in an Actor subclass, would I need to rewrite all the code in the World class to run the hands?
danpost danpost

2015/3/10

#
1920 wrote...
would I need to rewrite all the code in the World class to run the hands?
This code appears to be in an Actor subclass. I would think the general running of the hands should be done in your World subclass.
I need not say more.
You need to login to post a reply.