HumanPlayer.java Game game Add a setter for member variable of class Game If tru
ID: 3918575 • Letter: H
Question
HumanPlayer.java
Game game
Add a setter for member variable of class Game
If true, display a message dialog to the player (i.e. the dealer) that they have to accept trump
Call method setAcceptTrump passing as an argument the value true
Create a local variable set equal to JOptionPane.showConfirmDialog static method call prompting the human player if they accept the trump suit
Call method setAcceptTrump() passing as an argument the value true
Call method setAcceptTrump() passing as an argument the value false
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package core;
import constants.Constants.Face;
import constants.Constants.Suit;
import userinterface.HumanPlayerUi;
/**
*
* @author
*/
public class HumanPlayer extends Player
{
public Object getHand;
@Override
public Card playCard() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public void makeTrump()
{
}
}
HumanPlayer.java
Update class to add the following member variablesGame game
Add a setter for member variable of class Game
Update method makeTrump() so it does the followingChecks if the max number of passes has been reached (i.e. 3) by calling method getTrumpCheck from class GameIf true, display a message dialog to the player (i.e. the dealer) that they have to accept trump
Call method setAcceptTrump passing as an argument the value true
ElseCreate a local variable set equal to JOptionPane.showConfirmDialog static method call prompting the human player if they accept the trump suit
If the human player’s response is true,Call method setAcceptTrump() passing as an argument the value true
ElseCall method setAcceptTrump() passing as an argument the value false
Explanation / Answer
**** Modified Code is in bold.
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package core;
import constants.Constants.Face;
import constants.Constants.Suit;
import userinterface.HumanPlayerUi;
/**
*
* @author
*/
public class HumanPlayer extends Player
{
public Object getHand;
public Game gm;
public void setGame(Game g){
this.gm = g;
}
@Override
public Card playCard() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public void makeTrump()
{
if(getTrumpCheck() >= 3){
System.out.println("Limit for max number of passes reached!! Accept trump.");
setAcceptTrump(true);
}else {
int in = JOptionPane.showConfirmDialog(null, "Do you accept the trump suit?");
if(in == 0) {
// User clicked on yes
setAcceptTrump(true);
} else {
// User clicked on no or cancel
setAcceptTrump(false);
}
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.