Question
Tasks and Rubric Activity euchre package constants package Constants.java Update class to add the following constant MAX_PASSES = 3 MIN_TRUMP = 3 core package AiPlayer.java
Tasks and Rubric
Activity | ||
euchre package |
|
|
constants package |
|
|
Constants.java | Update class to add the following constant MAX_PASSES = 3 MIN_TRUMP = 3 |
|
core package |
|
|
AiPlayer.java | Update class to add the following member variables Game 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 to count how many cards the player has of the trump suit Loop through the players hand, for each card in their handCheck if the current cards suit matches the trump cards suit HINT: reference member variable of class Game calling method getTrump to retrieve the trump card Check if the trump counter is greater than or equal the value of 3 (e.g. this is a good indicator the team will win the hand)If true, call method setAcceptTrump() passing as an argument the value true Display a message dialog stating that the current player has said Pick it Up! ElseCall method setAcceptTrump() passing as an argument the value false Display a message dialog stating that the current player has said Pass! |
|
Game.java | Update class to add the following member variables int trumpCheck Team trumpTeam |
|
| Add a getter for member variable trumpCheck Update customer constructor Game() to do the followingComment out the call the method play() Update method createTeams() to do the followingOn the instance of class HumanPlayer, call method setGame() passing as an argument a reference to this class Game On the instance of class AiPlayer, call method setGame() passing as an argument a reference to this class Game Update method play() to do the followingComment out any current code Add a call to method trumpCheck Add method trumpCheck to do the followingReturn type void Empty parameter list Initialize member variable trumpCheck to the value of 0 Create a local variable of data type int to represent the current player, initialized to the member variable leadIdx Loop while the value of member variable trumpCheck is less than the number of playersInstantiate an instance of class Player set equal to member variable getting the player at the position represented by local variable created in step d. (i.e. starting with the lead player) On the Player object from above, call method makeTrump() Check if the Player object accepted the trump by calling method getAcceptTrump()If true, loop through the member variable of data type ArrayList that stores the teams in the game Check if the current team contains the current player (HINT: use method contains() that is part of the class ArrayList)If true, set the member variable trumpTeam equal to the current team Display a dialog message to state which team has accepted the trump suit Break out of the while loop if trump has been accepted ElseIncrement the member variable trumpCheck by one Increment the local variable representing the current player by one; be sure to check if the counter is equal to 3, then reset it to 0 (e.g. remember, the table member variable has only 4 elements so the maximum index is 3) |
|
HumanPlayer.java | Update class to add the following member variables Game 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 players response is true,Call method setAcceptTrump() passing as an argument the value true ElseCall method setAcceptTrump() passing as an argument the value false |
|
Player.java | Update class to add the following member variable boolean acceptTrump Generate a getter/setter for the member variable acceptTrump |
|
images package |
|
|
userInterface package |
|
|
AiPlayerUi.java | Update the class to add the following member variables GameUi gameUi Modify the custom constructor to do the followingAdd a third parameter of data type class GameUi On the member variable of class AiPlayer, call method setUi passing as an argument the parameter of class GameUi |
|
GameUi.java | Update the class to add the following member variables JPanel trumpPanel (if you added bidPanel in the last assignment, please rename it) JLabel teamOneScoreLbl JLabel teamOneScore JLabel teamTwoScoreLbl JLabel teamTwoScore JLabel trumpCard |
|
| Update the custom constructor to do the following Call method setGameUi() in class Game passing an instance to this class as an argument Call method play() in class Game Update initComponents to do the followingTrump PanelInstantiate the JPanel member variable for the trump panel Instantiate the JLabel member variable for the trump label Instantiate an instance of class CardUi passing as arguments to the constructor the followingJLabel member variable for the trump card The trump cards face value The trump cards suit Update the JLabel member variable for the trump to do the followingsetting it equal to method call getLabel on the instance of class CardUi add client property passing arguments face and the trump cards face value add client property passing arguments suit and the trump cards suit Add the trump card JLabel the trump panel Add the trump JPanel to the north JPanel Score PanelUse layout manager GridLayout so it is a 2 x 2 grid Instantiate the following member variables of class JLabelteamOneScoreLbl with text Team One teamOneScore with text using the following method call: game.getTeams().get(Constants.ONE).getTeamScore() teamTwoScoreLbl with text Team Two teamTwoScore with text using the following method call: game.getTeams().get(Constants.TWO).getTeamScore() Add the four JLabels to the score JPanel Add the score JPanel the the north JPanel For the four player JPanels, aiOnePanel, aiTwoPanel, aiThreePanel, and hpPanelAdd an additional argument to the constructor calls a reference to this class, GameUi |
|
HumanPlayerUi.java | Update the class to add the following member variables GameUi gameUi Modify the custom constructor to do the followingAdd a second parameter of data type class GameUi On the member variable of class HumanPlayer, call method setUi passing as an argument the parameter of class GameUi |
|
constants:
/* * 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 constants;
/** * * @author roxsinegron */ public class Constants { public static final int NUM_AI_PLAYERS = 3; public static final int NUM_CARDS = 24; public static final int CARDS_EACH = 5; public static final int ONE = 0; public static final int TWO = 1; public static final int NUM_PLAYERS = 4; public static final int DEAL_ONE = 2; public static final int DEAL_TWO = 3; public static final int POSITION_1 = 0; public static final int POSITION_2 = 1; public static final int POSITION_3 = 2; public static final int POSITION_4 = 3;
public enum Color { RED, BLACK } public enum Suit { CLUBS (0), DIAMONDS (1), HEARTS (2), SPADES (3); private int rank; public int getRank() { return rank; } private Suit(int rank) { this.rank = rank; } } public enum Face { NINE (9), TEN (10), JACK (11), QUEEN (12), KING (13), ACE (14); private int value; public int getValue() { return value; } private Face(int value) { this.value = value; } } }
AiPlayer:
/* * 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 javax.swing.JOptionPane; import userinterface.AiPlayerUi;
/** * * @author roxsinegron */ public class AiPlayer extends Player { AiPlayerUi aiUi; @Override public Card playCard() { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public void makeTrump() { } }
Game:
/* * 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;
/** * * @author roxsinegron */
import constants.Constants; import constants.Constants.Suit; import java.util.ArrayList; import java.util.Iterator; import java.util.Random; import java.util.Scanner; import javax.swing.JFrame; import javax.swing.JOptionPane; import userinterface.GameUi;
public class Game { // member variables private Card trump; private Player leadPlayer; private Player dealer; private Player wonTrick; private int round; private ArrayList
private void outputTeams() { for(Team team : teams) { team.outputTeam(); } } private void setTable() { // players are set up so that team members sit across from each other // therefore the deal would be to TeamOne.PlayerOne, TeamTwo.PlayerTwo, // TeamOne.PlayerTwo, TeamTwo.PlayerTwo as an example table = new ArrayList(); // get the teams in the game Team teamOne = teams.get(Constants.ONE); Team teamTwo = teams.get(Constants.TWO); // get the players from each team Player teamOnePlayerOne = teamOne.getTeam().get(Constants.ONE); Player teamOnePlayerTwo = teamOne.getTeam().get(Constants.TWO); Player teamTwoPlayerOne = teamTwo.getTeam().get(Constants.ONE); Player teamTwoPlayerTwo = teamTwo.getTeam().get(Constants.TWO); // we want to explicitly dictate which seat each player is in so we are // using the add method that takes two arguments, one to set the position // in the ArrayList and the associated object at that position table.add(0, teamOnePlayerOne); table.add(1, teamTwoPlayerOne); table.add(2, teamOnePlayerTwo); table.add(3, teamTwoPlayerTwo); System.out.println("************************"); System.out.println("Players at the table are"); System.out.println("************************");
for(Player player : table) { System.out.println(player.getName()); } } private void setDealerAndLead() { // select the first dealer Random random = new Random(); dealerIdx = random.nextInt(Constants.NUM_PLAYERS); dealer = table.get(dealerIdx); // create an index to keep track of which player got the card; // reset when get to 3 // set the leadIdx based on which player was selected as the dealer and // add one to it if(dealerIdx < 3) leadIdx = dealerIdx + 1; else leadIdx = 0; leadPlayer = table.get(leadIdx); } private void dealHand() { setDealerAndLead(); System.out.println("********************************"); System.out.println(" DEALING THE HAND"); System.out.println("********************************");
System.out.println("Player " + dealer.getName() + " will deal the hand");
int playerIdx = leadIdx; // loop through the shuffled deck and deal five cards to each player // first round, two at a time // second round, three at a time Iterator
for(int p = 0; p < Constants.NUM_PLAYERS; p++) { dealOne(playerIdx, currentCard); // increment the player index until value of 3, then reset to 0 if(playerIdx == 3) playerIdx = 0; else playerIdx++; }
// System.out.println("********************************"); // System.out.println(" SECOND DEAL, THREE CARDS EACH"); // System.out.println("********************************");
for(int p = 0; p < Constants.NUM_PLAYERS; p++) { dealTwo(playerIdx, currentCard); // increment the player index until value of 3, then reset to 0 if(playerIdx == 3) playerIdx = 0; else playerIdx++; } // set trump to next card on deck trump = currentCard.next(); System.out.println("********************************"); System.out.println("Trump card is " + trump.getFace() + " of " + trump.getSuit() + " color " + trump.getColor()); System.out.println("********************************"); }
public Card getTrump() { return trump; } private void dealOne(int playerIdx, Iterator
// System.out.println("Dealing " + card.getFace() + " of " + // card.getSuit() + " to player " + // table.get(playerIdx).getName()); // add card to a player's hand table.get(playerIdx).getHand().add(card); // remove the card from the deck after it has been dealt currentCard.remove(); } } } private void dealTwo(int playerIdx, Iterator
// System.out.println("Dealing " + card.getFace() + " of " + // card.getSuit() + " to player " + // table.get(playerIdx).getName()); // add card to a player's hand table.get(playerIdx).getHand().add(card);
// remove the card from the deck after it has been dealt currentCard.remove(); } } } private void displayHands() { for(Team team : teams) { team.outputHands(); } } private void createDeck() { deck = new Deck(); } public void play() { for(Player player : table) { player.makeTrump(); } } public void setGameUi(GameUi ui) { this.ui = ui; } /** * @return the wonTrick */ public Player getWonTrick() { return wonTrick; }
/** * @param wonTrick the wonTrick to set */ public void setWonTrick(Player wonTrick) { this.wonTrick = wonTrick; }
/** * @return the round */ public int getRound() { return round; }
/** * @param round the round to set */ public void setRound(int round) { this.round = round; }
/** * @return the leadPlayer */ public Player getLeadPlayer() { return leadPlayer; }
/** * @param leadPlayer the leadPlayer to set */ public void setLeadPlayer(Player leadPlayer) { this.leadPlayer = leadPlayer; }
/** * @return the dealer */ public Player getDealer() { return dealer; }
/** * @param dealer the dealer to set */ public void setDealer(Player dealer) { this.dealer = dealer; }
/** * @return the table */ public ArrayList
HumanPlayer:
/* * 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 roxsinegron */ 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() { }
}
Player:
/* * 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 java.util.ArrayList; import javax.swing.JPanel;
/** * * @author roxsinegron */ public abstract class Player implements IPlayer { // member variables private String name; private int tricks; private int score; private ArrayList
public Player() { hand = new ArrayList(); } public void setUi(JPanel ui) { this.ui = ui; } public JPanel getUi() { return ui; }
public void sortBySuit() { /** * Sorts the cards in the hand so that cards are sorted into * order of increasing value. Cards with the same value * are sorted by suit. Note that aces are considered * to have the highest value. */ ArrayList
/** * @param name the name to set */ public void setName(String name) { this.name = name; }
/** * @return the tricks */ public int getTricks() { return tricks; }
/** * @param tricks the tricks to set */ public void setTricks(int tricks) { this.tricks = tricks; }
/** * @return the bid */
/** * @return the score */ public int getScore() { return score; }
/** * @param score the score to set */ public void setScore(int score) { this.score = score; }
/** * @return the hand */ public ArrayList
/** * @param hand the hand to set */ public void setHand(ArrayList
AiPlayerUi:
/* * 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 userinterface;
import constants.Constants; import constants.Constants.Face; import constants.Constants.Suit; import core.AiPlayer; import core.Player; import java.awt.Color; import java.awt.Dimension; import java.util.ArrayList; import javax.swing.BorderFactory; import javax.swing.BoxLayout; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JPanel;
/** * * @author roxsinegron */ public class AiPlayerUi extends JPanel { private AiPlayer ai; private int position; private ArrayList
if(position == 1 || position == 3) { this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); this.width = 100; this.height = 50; } else { this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); this.width = 50; this.height = 100; } displayCards(); } private void displayCards() { cards = new ArrayList
for(int c = 0; c < Constants.CARDS_EACH; c++) { JLabel card = new JLabel(); cardUi = new CardUi(ai.getHand().get(c), card, position); card = cardUi.getLabel(); card.setMinimumSize(new Dimension(width, height)); card.setPreferredSize(new Dimension(width, height)); card.setBorder(BorderFactory.createLineBorder(Color.BLACK)); //add clientProperties card.putClientProperty("position", c); card.putClientProperty("face", ai.getHand().get(c).getFace()); card.putClientProperty("suit", ai.getHand().get(c).getSuit()); cards.add(card); this.add(card); } } }
GameUi:
/*
* 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 userinterface;
import constants.Constants;
import constants.Constants.Face;
import constants.Constants.Suit;
import core.Card;
import core.Game;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import static java.time.Clock.system;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
/**
*
* @author kwhiting
*/
public class GameUi
{
// the game
private Game game;
// the layout
private JFrame frame;
private JPanel aiOnePanel;
private JPanel tablePanel;
private JPanel aiTwoPanel;
private JPanel hpPanel;
private JPanel aiThreePanel;
private JPanel northPanel;
private JPanel scorePanel;
private JPanel trumpPanel;
// the menu
private JMenuBar menuBar;
private JMenu gameMenu;
private JMenu helpMenu;
private JMenuItem newGameMenuItem;
private JMenuItem exitMenuItem;
private JMenuItem aboutMenuItem;
private JMenuItem rulesMenuItem;
//other components
private JLabel teamOneScoreLbl;
private JLabel teamnOneScore;
private JLabel teamTwoScoreLbl;
private JLabel teamTwoScore;
private JLabel trumpCard;
private ArrayList
private ArrayList
public GameUi(Game game)
{
this.game = game;
initComponents();
game.setGameUi(this);
game.play();
}
private void initComponents()
{
initMenuBar();
layoutTable();
}
private void initMenuBar()
{
menuBar = new JMenuBar();
// game menu
gameMenu = new JMenu("Game");
newGameMenuItem = new JMenuItem("New Game");
newGameMenuItem.addActionListener(new NewGameListener());
exitMenuItem = new JMenuItem("Exit");
exitMenuItem.addActionListener(new ExitListener());
// help menu
helpMenu = new JMenu("Help");
aboutMenuItem = new JMenuItem("About");
aboutMenuItem.addActionListener(new AboutListener());
rulesMenuItem = new JMenuItem("Game Rules");
rulesMenuItem.addActionListener(new RulesListener());
// put it all together
gameMenu.add(newGameMenuItem);
gameMenu.add(exitMenuItem);
helpMenu.add(aboutMenuItem);
helpMenu.add(rulesMenuItem);
menuBar.add(gameMenu);
menuBar.add(helpMenu);
}
private void layoutTable()
{
// create the jframe
frame = new JFrame("Euchre");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(700, 700);
// create the player's panels
aiOnePanel = new AiPlayerUi(game.getTable().get(Constants.POSITION_2), Constants.POSITION_2, this);
aiTwoPanel = new AiPlayerUi(game.getTable().get(Constants.POSITION_3), Constants.POSITION_3, this);
aiThreePanel = new AiPlayerUi(game.getTable().get(Constants.POSITION_4), Constants.POSITION_4, this);
hpPanel = new HumanPlayerUi(game.getTable().get(Constants.POSITION_1), this);
game.getTable().get(Constants.POSITION_1).setUi(hpPanel);
game.getTable().get(Constants.POSITION_2).setUi(aiOnePanel);
game.getTable().get(Constants.POSITION_3).setUi(aiTwoPanel);
game.getTable().get(Constants.POSITION_4).setUi(aiThreePanel);
initNorthPanel();
initTablePanel();
// add UI components
frame.add(aiOnePanel, BorderLayout.WEST);
frame.add(northPanel, BorderLayout.NORTH);
frame.add(aiThreePanel, BorderLayout.EAST);
frame.add(hpPanel, BorderLayout.SOUTH);
frame.add(tablePanel, BorderLayout.CENTER);
frame.setJMenuBar(menuBar);
frame.setVisible(true);
}
private void initNorthPanel()
{
northPanel = new JPanel();
northPanel.setMinimumSize(new Dimension(680, 170));
northPanel.setPreferredSize(new Dimension(680, 170));
initScorePanel();
initTrumpPanel();
aiTwoPanel.setMinimumSize(new Dimension(350, 160));
aiTwoPanel.setPreferredSize(new Dimension(350, 160));
northPanel.add(scorePanel);
northPanel.add(aiTwoPanel);
northPanel.add(trumpPanel);
}
private void initTablePanel()
{
tablePanel = new JPanel();
tablePanel.setBorder(BorderFactory.createTitledBorder("EUCHRE"));
tablePanel.setMaximumSize(new Dimension(300,200));
tablePanel.setMinimumSize(new Dimension(300,200));
tablePanel.setPreferredSize(new Dimension(300,200));
}
private void initScorePanel()
{
scorePanel = new JPanel();
scorePanel.setBorder(BorderFactory.createTitledBorder("Scores"));
scorePanel.setMinimumSize(new Dimension(130, 160));
scorePanel.setPreferredSize(new Dimension(130, 160));
}
private void initTrumpPanel()
{
trumpPanel = new JPanel();
trumpPanel.setBorder(BorderFactory.createTittledBorder("Trump"));
trumpPanel.setMinimumSize(new Dimension(130, 160));
trumpPanel.setPreferredSize(new Dimension(130, 160));
trumpPanel.setLayout(new BoxLayout("trumpPanel, BoxLayout.X_AXIS"));
// trump card
trumpCard = new JLabel();
CardUi cardUi = new CardUi(trumpCard, game.getTrump().getFace(), game.getTrump);
trumpCard = cardUi.getLabel();
trumpCard.setMinimumSize(new Dimension(100, 160));
trumpCard.setPreferredSize(new Dimension(100,160));
trumpCard.setMaximumSize(new Dimension(100,160));
//addclientProperties
trumpCard.putClientProperty("face", game.getTrump.getFace());
trumpCard.putClientProperty("suit", game.getTrump.getSuit());
trumpPanel.add(trumpCard);
}
public void updateTabelPanel(JComponent cmpt)
{
System.out.println("updatetablepanel");
Face face = (Constants.Face)cmpt.getClientProperty("face");
Suit suit = (Constants.Suit)cmpt.getClientProperty("suit");
JLabel cardLbl = new JLabel();
CardUi cardUi = new CardUi(cardLbl,face,suit);
cmpt = cardUi.getLabel();
Card card = new Card();
card.setFace(face);
card.setSuit(suit);
tablePanel.add(cmpt);
try
{
Thread.sleep(2000);
}
catch(Exception ex)
{
ex.printStackTrace();
}
//game.setSuitlead(suit);
//game.addPlayercard(card);
}
public void clearTablePanel()
{
System.out.println("Clearing table");
//for(int c = 0 ; tablePanel.getComponentCount();C++)
tablePanel.removeAll();
tablePanel.revalidate();
tablePanel.repaint();
}
public JFrame getFrame()
{
return frame;
}
public ArrayList
{
return cardsPlayed;
}
public void addCardPlayed(Card card)
{
cardsPlayed.add(card);
}
public Game getGame()
{
return null;
}
// inner classes
private class NewGameListener implements ActionListener
{
@Override
public void actionPerformed(ActionEvent ae)
{
}
}
private class ExitListener implements ActionListener
{
@Override
public void actionPerformed(ActionEvent ae)
{
int response = JOptionPane.showConfirmDialog(frame, "Confirm to exit Euchre?",
"Exit?", JOptionPane.YES_NO_OPTION);
if (response == JOptionPane.YES_OPTION)
System.exit(0);
}
}
private class AboutListener implements ActionListener
{
@Override
public void actionPerformed(ActionEvent ae)
{
String message = "Euchre version 1.0 Karin Whiting Summer 2018";
JOptionPane.showMessageDialog(frame, message);
}
}
private class RulesListener implements ActionListener
{
@Override
public void actionPerformed(ActionEvent ae)
{
String message = "Euchre version 1.0 Roxsi Negron Summer 2018";
JOptionPane.showMessageDialog(frame, message);
}
private class RulesListener implements ActionListener
{
public void ActionPerformed(ActionEvent ae)
}
}
}
HumanPlayerUi:
/* * 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 userinterface;
import core.HumanPlayer; import core.Player; import constants.Constants; import constants.Constants.Face; import constants.Constants.Suit; import core.Card;
import java.awt.Color; import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; import java.util.logging.Logger; import javax.swing.BorderFactory; import javax.swing.BoxLayout; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel;
/** * * @author roxsinegron */ public class HumanPlayerUi extends JPanel { private HumanPlayer human; private ArrayList
displayCards(); } private void displayCards() { cards = new ArrayList
for(int c = 0; c < Constants.CARDS_EACH; c++) { // instantiate the JButton JButton card = new JButton(); // update the JButton and format it card = cardUi.getButton(); card.setMinimumSize(new Dimension(60,100)); card.setPreferredSize(new Dimension(60,100)); card.setBorder(BorderFactory.createLineBorder(Color.BLACK)); Object C = null; //add clientProperties card.putClientProperty("position", C); card.putClientProperty("face", human.getHand.get(c).getFace()); card.putClientProperty("Suit", human.getHand.get(c).getSuit()); //register an ActionListener card.addActionListerner(new CardListener()); // add the object to the the ArrayList and UI cards.add(card); for(JButton button : cards) this.add(button); } }
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started