Question: I need to create a java class that does the following: 1. Add member variables: Game game; JFrame frame; JPanel aiOnePanel; JPanel tablePanel; JPanel aiTwoPanel;

I need to create a java class that does the following:

1. Add member variables:

Game game;

JFrame frame;

JPanel aiOnePanel;

JPanel tablePanel;

JPanel aiTwoPanel;

JPanel hpPanel;

JPanel aiThreePanel;

JPanel northPanel;

JPanel scorePanel;

JPanel bidPanel;

JMenuBar menuBar;

JMenu gameMenu;

JMenu helpMenu;

JMenuItem newGameMenuItem;

JMenuItem exitMenuItem;

JMenuItem aboutMenuItem;

JMenuItem rulesMenuItem;

2. A custom constructor should be defined that receives a parameter of data type Game class

a) Set member variable of type class Game to the parameter passed in

b) Call method initComponents()

3. A method initComponents() should initialize all the components for the UI and be called from the constructor

a) Set the size of the JFrame

b) Set the default close operation of the JFrame

c) Use default layout manager BorderLayout

d) Set up the JMenuBar

i) JMenu Game should be added to the JMenuBar

ii) JMenuItems New Game and Exit should be added to the JMenu Game

iii) JMenu Help should be added to the JMenuBar

iv) JMenuItems About and Game Rules should be added to the JMenu Help

e) JMenuBar should be set on the JFrame

f) Instantiate member variable aiOnePanel by calling the constructor for class AiPlayerUi, passing as arguments

i) the instance of class Player stored in class Game, member variable table, at the second position of the ArrayList

ii) An integer representing the position of the Player object in the ArrayList

iii) Example: aiOnePanel = new AiPlayerUi(game.getTable().get(Constants.POSITION_2), Constants.POSITION_2);

g) Instantiate member variable aiTwoPanel by calling the constructor for class AiPlayerUi, passing as arguments

i) the instance of class Player stored in class Game, member variable table, at the second position of the ArrayList

ii) An integer representing the position of the Player object in the ArrayList

h) Instantiate member variable aiThreePanel by calling the constructor for class AiPlayerUi, passing as arguments

i) the instance of class Player stored in class Game, member variable table, at the second position of the ArrayList

ii) An integer representing the position of the Player object in the ArrayList

i) Instantiate member variable humanPanel by calling the constructor for class HumanPlayerUi, passing as an argument

i) the instance of class Player stored in class Game, member variable table, at the second position of the ArrayList

j) Instantiate member variable northPanel and set the size of the JPanel using the default layout manager FlowLayout

k) Instantiate member variable bidPanel and do the following

i) Set the size of the JPanel

ii) Add a border to the JPanel

l) Instantiate member variable scorePanel and do the following

i) Set the size of the JPanel

ii) Add a border to the JPanel

m) Resize aiPanelTwo so it will fit in the northPanel with bidPanel and scorePanel

n) Add to northPanel

i) scorePanel

ii) aiTwoPanel

iii) bidPanel

o) Instantiate member variable tablePanel and do the following

i) Set the size of the JPanel

ii) Add a border to the JPanel

p) Add the JPanels to the JFrame in their appropriate locations based on using layout manager BorderLayout

q) Set the visibility of the JFrame

4. Write an inner class to create an ActionListener that is registered to the JMenuItem with the text Exit; it should

a) Display a JOptionPane message confirming the user wants to exit using method showConfirmDialog()

b) If yes, exit the application by calling method System.exit() passing the value of 0 as an argument

c) If no, do not exit the application

5. Write an inner class to create an ActionListener that is registered to the JMenuItem with the text About using method showMessageDialog(); it should

a) Display a JOptionPane message informing the user:

i) Application name and version

ii) Date of development

6. Write an inner class to create an ActionListener that is registered to the JMenuItem with the text Game Rules using method showMessageDialog(); it should

a) Display a JOptionPane message informing the user:

i) Rules of the game as shown in Figure 6 below (displaying something simple like "game rules" is enough)

Class player: public abstract class Player implements IPlayer

{ private String name; private int tricks; private int bid; private int score; private ArrayList hand;

Class IPlayer: public interface IPlayer { public Card playCard(); public int placeBid(); }

Class game: public class Game { private Suit trump = Suit.SPADES; private Player leadPlayer; private Player dealer; private Player wonTrick; private int round; private ArrayList teams; private Deck deck; private Scanner scan; private ArrayList table; private int dealerIdx;

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!