COP3330 Object Oriented Programming Euchre Project Part 4 Solved

30.00 $

Category:
Click Category Button to View Your Next Assignment | Homework

You'll get a download link with a: . zip solution files instantly, after Payment

Description

Rate this product

Assignment Scope

  1. Update classes due to changing requirements
  2. Adding fields to enumerations
  3. Add methods to classes to accomplish specific tasks
  4. Begin developing the front end, or User Interface, portion of the Euchre game. Based on my professional experience working in the industry I have always had to develop a UI for every application, therefore I translate that experience to students so they can have the same opportunity and be prepared professionally.
  5. Typically, there is a one-to-one correlation of back end functionality to front end UI component. Depending upon the design of the application it doesn’t always correlate perfectly, however with Euchre, it works well.

 

Back-end functionality Front-end UI component
AiPlayer.java AiPlayerUi.java
Card.java CardUi.java
Game.java GameUi.java
HumanPlayer.java HumanPlayerUi.java

 

  1. The goal is to develop the front-end components of the game Euchre by creating classes:
  2. java
  3. java
  4. java
  5. Students will also begin to learn writing simple ActionListeners or Event Handlers.
  6. The UI will be developed in multiple assignments, it is not expected that for Assignment 7 the fully functioning UI is complete.

 

The image that follows is a prototype of what the UI will look like.  It does not have to be an exact match.  The rubric will provide guidance and recommendations on how to accomplish this, however feel free to be creative in developing the look and feel of the UI.

 

References

  1. docx
  2. Setting up a project in Netbeans.docx
  3. Netbeans right click menu help.docx

 

Prototype

 

 

Deliverables

To complete this assignment you must submit your compressed Netbeans project to Webcourses.

 

Please keep in mind that the tasks are guidance to accomplish the goals of the assignment.  At times students will be required to do additional research (e.g. Google That S**T (GTS)!) to find implementation options.  In the industry, software engineers are expected to be very self-sufficient to find the best solution for the task at hand.

 

I have provided multiple code examples on Webcourses that shows how to implement numerous of the tasks below, please reference those code examples prior to asking me for help!   

 

Tasks

Activity
Euchre project  
Euchre class 1.      Add to method main()

Instantiate an instance of class GameUi, passing the reference object of class Game as an argument

constants  
Constants class  
  1.      Update enum Face to include the following

a.       Nine has the value of 9

b.      Ten has the value of 10

c.       Jack has the value of 11

d.      Queen has the value of 12

e.       King has the value of 13

f.        Ace has the value of 14

g.      Add field value of data type int

h.      Add a public getter to return the field value

i.        Add a private constructor for enum Face with one parameter of type int; set the field value to the parameter passed in

2.      Update enum Suit to include the following

a.       Clubs has the rank of 0

b.      Diamonds has the rank of 1

c.       Hearts has the rank of 2

d.      Euchre has the rank of 3

e.       Add field rank of data type int

f.        Add a public getter to return the field rank

g.      Add a private constructor for enum Suit with one parameter of type int; set the field rank to the parameter passed in

h.      Example code:

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;

}

}

 

core package  
AiPlayer class  
Card class  
Deck class Update class to do the following:

a.       Add member variable of interface List, specifically only allowing for instances of class Card to be added named cardList

b.      Generate the getter/setter for the member variable above

c.       Update method shuffleDeck() so that it instantiates the member variable cardList instead of creating a new instance of interface List

d.      Write method displayCardList so that is does the following:

a.       Return type void

b.      Empty parameter list

c.       Using an enhanced for loop, loop through the ArrayList of cards and output to the console the card value, face, and color

e.       Update the customer constructor to do the following:

a.       Calls method shufflDeck again

b.      Calls method displayCardList

Game class Update the class to do the following:

a.       Custom constructor Game()

a.       Comment out the call to method outputTeams()

b.      Add call to method play()

b.      Update method setTable() to do the following:

a.       Using an enhanced for loop output the names of each Player in the member variable table representing the setup of the players seated at the table

c.       Update method dealHand() where the Iterator instance is instantiated, change method call getDeck() in class Deck to method call getCardList()

d.      Update method dealOne() to comment out any System.out.println() statements that show what card each player is being dealt if they exist

e.       Update method dealTwo() to comment out any System.out.println() statements that show what card each player is being dealt if they exist

f.        Create method play() to do the following:

a.       Return type of void

b.      Empty parameter list

c.       Using an enhanced for loop, loop through the players at the table; for each player, call method makeTrump()

g.      Update method createTeams

a.       Replace the use of the console prompt and class Scanner to get the human player’s name with static method call on class JOptionPane using method showInputDialog passing as an argument the explicit text to prompt the human to enter their name

b.      Store the data entered in the input dialog in the variable of type String

h.      Add a getter ONLY for member variable of data type class ArrayList that represents the table of players

HumanPlayer class  
IPlayer interface  
Player class Update class to include the following:

a.       Add method sortBySuit() to do the following:

a.       Instantiate an instance of class ArrayList allowing only for instances of class Card to be elements that represents the sorted hand

b.      Loop while the size of member variable hand is greater than zero (0)

i.      Create a local variable of type int representing the current position in the ArrayList of member variable hand, initialize it to zero (0)

ii.      Instantiate and instance of class Card (reference as firstCard) set equal to the first element in the ArrayList of member variable hand (hint: use the .get() method of class ArrayList)

iii.      Using a for loop, starting at index 1, loop through the size of member variable ArrayList hand to do the following:

1.      Instantiate an instance of class Card (reference as nextCard) set equal to the next element in the ArrayList hand (i.e. index 1)

2.      Write an if statement to sort the cards based on suit and face value ranking with the following logic:

a.       If the suit’s rank of the nextCard in the hand is less than the suit’s rank of the firstCard in the hand

b.      OR

i.      The suit of the nextCard is equal to the suit of the firstCard

ii.      AND

iii.      The face value of the nextCard in the hand is less than the face value of the firstCard in the hand

1.      Update local variable position to equal the for loop’s looping variable

2.      Set the firstCard equal to the nextCard

iv.      Remove from the member variable hand the card at the current position (hint: on member variable hand call method remove() passing the argument defined in step i.)

v.      Add the instance represented as firstCard to the local ArrayList that represents the sorted hand created in step a.

c.       Set member variable hand equal to the local ArrayList that represents the sorted hand.

Team class Update method outputHands() to do the following:

a.       Call method sortBySuit() for each player

b.      Only call method displayHand() if the player is an instanceof class HumanPlayer

userinterface package  
GameUi.java 1.      Add member variables of type

a.       Game game;

b.      JFrame frame;

c.       JPanel aiOnePanel;

d.      JPanel tablePanel;

e.       JPanel aiTwoPanel;

f.        JPanel hpPanel;

g.      JPanel aiThreePanel;

h.      JPanel northPanel;

i.        JPanel scorePanel;

j.        JMenuBar menuBar;

k.      JMenu gameMenu;

l.        JMenu helpMenu;

m.    JMenuItem newGameMenuItem;

n.      JMenuItem exitMenuItem;

o.      JMenuItem aboutMenuItem;

p.       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 scorePanel and do the following

i.      Set the size of the JPanel

ii.      Add a border to the JPanel

l.        Resize aiPanelTwo so it will fit in the northPanel with scorePanel

m.    Add to northPanel

i.      scorePanel

ii.      aiTwoPanel

n.      Instantiate member variable tablePanel and do the following

i.      Set the size of the JPanel

ii.      Add a border to the JPanel

o.      Add the JPanels to the JFrame in their appropriate locations based on using layout manager BorderLayout

p.      Set the visibility of the JFrame (hint: this should ALWAYS be the last step on a UI)

 
  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:

a.       Application name and version

b.      Author

c.       Date of development

 
  6.      Write an inner class to create an ActionListener that is registered to the JMenuItem with the text Game Rules  
AiPlayerUi.java 1.      Create class AiPlayerUi so it uses class JPanel as the superclass

2.      Add member variables of type:

a.       AiPlayer ai;

b.      int position;

c.       ArrayList<JLabel> cards;

 
  3.      A custom constructor should be defined that receives a two parameters; one is data type class Player, the other is data type int

a.       Set member variable of type class AiPlayer to the parameter passed in of class Player using an explicit type cast

b.      Set member variable position to the parameter of data type int

c.       Call method initComponents()

 
  4.      Write method initComponents() to initialize all the components for the UI and be called from the constructor

a.       Set the size of the JPanel using two methods to ensure the UI isn’t too small

i.      setMinimumSize()

ii.      setPreferredSize()

b.      Instantiate the member variable of data type ArrayList containing elements of class JLabel

c.       Using an if statement check if the position is 1 or 3

i.      If true, set the layout manager to use BoxLayout so it is aligned on the Y axis

ii.      Else, set the layout manager to use BoxLayout so it is aligned on the X axis

d.      Call method displayCards()

 
  5.      Write method displayCards to do the following

a.       Loop through the member variable of data type ArrayList containing elements of class JLabel so there are 5 JLabels

i.      Instantiate an instance of class JLabel

ii.      Set the size of the JLabel

iii.      Add a border to the JLabel

iv.      Set the text of the JLabel to explicit text “Card” concatenated with the looping variable

v.      Add the JLabel to the ArrayList

vi.      Add the JLabel to the JPanel

 
HumanPlayerUi.java 1.      Create class HumanPlayerUi so it uses class JPanel as the superclass

2.      Add member variables of type:

a.       HumanPlayer human;

b.      ArrayList<JButton> cards;

 
  3.      A custom constructor should be defined that receives a one parameter,  data type class Player

a.       Set member variable of type class HumanPlayer to the parameter passed in of class Player using an explicit type cast

b.      Call method initComponents()

 
  4.      Write method initComponents() to initialize all the components for the UI and be called from the constructor

a.       Set the size of the JPanel using two methods to ensure the UI isn’t too small

b.      setMinimumSize()

c.       setPreferredSize()

d.      Instantiate the member variable of data type ArrayList containing elements of class JButton

e.       Se the layout manager to use BoxLayout so it is aligned on the X axis

f.        Call method displayCards()

 
  5.      Write method displayCards to do the following

a.       Loop through the member variable of data type ArrayList containing elements of class JButton so there are 5 JButtons

i.            Instantiate an instance of class JButton

ii.            Set the size of the JButton

iii.            Add a border to the JButton

iv.            Set the text of the JButton to explicit text “Card” concatenated with the looping variable

v.            Add the JButton to the ArrayList

vi.            Add the JButton to the JPanel

 
     
CardUi.java Create the class  
Euchre application  
   
Test Case 1 Test Case 1 passes
Test Case 2 Test Case 2 passes
Test Case 3 Test Case 3 passes
Test Case 4 Test Case 4 passes
Test Case 5 Test Case 5 passes
Test Case 6 Test Case 6 passes
Test Case 7 Test Case 7 passes
Test Case 8 Test Case 8 passes
Test Case 9 Test Case 9 passes
Test Case 10 Test Case 10 passes
Test Case 11 Test Case 11 passes
  Source compiles with no errors
  Source runs with no errors
  Source includes comments

 

Perform the following test cases

Test Cases
  Action Expected outcome
Test Case 1 Project view Completed project view should look like figure 1
Test Case 2 Regression testing; Run application The JOptionPane.showMessageDialog() method call should look like figure 2
Test Case 3 Run application;

Updated method setTable()

Output should be similar to figure 3
Test Case 4 Run application;

Updated method .displayHands()

Output should be similar to figure 4 where only the human player’s hand is displayed
Test Case 6 JOptionPane Prompts User Name JOptionPane is similar to figure 5
Test Case 7 Euchre Initial UI displays Game UI looks similar figure 6
Test Case 8 Euchre Game Menu Game menu looks similar to figure 7
Test Case 9 Euchre Help Menu Help menu looks similar to figure 8
Test Case 10 About Menu Item Action Listener JOptionPane displays similar to figure 9
Test Case 11 Exit Menu Item Action Listener JOptionPane displays similar to figure 10

if user selects yes, the application should exit;

if user selects no, the application continues to run

 

 

Figure 1 Project View

 

Figure 2 Display from JOptionPane.showMessageDialog() method

 

Figure 3 Prompt for User’s Name

 

Figure 4 Players at the table

Figure 5 Only human player sorted hand should display

 

Figure 6 Euchre Initial UI

 

Figure 7 Game Menu

 

Figure 8 Help Menu

 

Figure 9 About Menu Item

 

Figure 10 Exit

 

 

  • Assignment_5.zip