For this assignment students will continue 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.
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 |
The goal is to develop the front-end components of the game Euchre by creating or updating classes:
- java
- java
- java
- java
The UI will be developed in multiple assignments, it is not expected that for Part 5 the fully functioning UI is complete.
The image that follows is a what my version of the UI will looks 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.
To accomplish this:
- Reference the tasks below for the specifics of the source code requirements.
- Compress a project and submit to Webcourses
- Decompress compressed project and verify it is a Netbeans project
References
- docx
- Setting up a project in Netbeans.docx
- Netbeans right click menu help.docx
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 and Rubric
| Activity | ||
| euchre package | ||
| core package | ||
| Game.java | 1. Update class to add the following member variable
a. GameUi ui |
|
| 2. Add method setGameUi to do the following
a. Return type void b. One parameter of data type GameUi c. Set member variable ui equal to parameter 3. Add method getTeams to do the following a. Return type ArrayList<Team> b. Empty parameter list c. Returns the member variable of data type ArrayList that contains elements of class Team 4. Add method getTrump to do the following a. Return type Card b. Empty parameter list c. Returns the member variable of data type Card that represents the trump card for the dealt hand |
||
| Player.java | 1. Update class to add the following member variable
a. JPanel ui 2. Generate a getter/setter for the member variable ui |
|
| images package | 1. Add package images to the project
2. Add images for the cards to the package |
|
| userInterface package | ||
| GameUi.java | 1. Update the class to add the following member variables
a. JPanel trumpPanel (if you added bidPanel in the last assignment, please rename it) b. JLabel teamOneScoreLbl c. JLabel teamOneScore d. JLabel teamTwoScoreLbl e. JLabel teamTwoScore f. JLabel trumpCard |
|
| 2. Update initComponents to do the following
a. Instantiate the member variable of class ArrayList containing elements of class JLabel that represents the card each player plays on the table JPanel b. Loop through the four players and do the following 1. Instantiate an instance of class JLabel 2. Based on the position of the player set the size of the JLabel using class Dimension to be horizontal or vertical width and height 3. Instantiate an instance of class CardUi passing the JLabel from step 1 as an argument 4. Set the instance of class JLabel from step 1 equal to method call getLabel() on class CardUi 5. Add the instance of class JLabel from step 1 to the member variable of call ArrayList containing element of class JLabel representing the cards played on the table c. Add each instance of class JLabel stored in the ArrayList containing elements of class JLabel representing the cards played so that 1. Human player JLabel for card played is in the SOUTH 2. The remaining AI players have a JLabel placed in from of their position at the table |
||
| AiPlayerUi.java | 1. Update the class to add the following member variables
1. CardUi cardUi; 2. int width; 3. int height; |
|
| 2. Update method initComponents() to do the following
a. Set the member variables width and height based on the orientation of the cards, vertical or horizontal |
||
| 3. Update method displayCards() to do the following
a. In the for loop i. Instantiate the instance of class CardUi passing as arguments 1. The instance of class Card in the player’s hand at the looping variable’s index 2. The instance of class JLabel created inside the for loop 3. The Player’s position at the table ii. Set local variable of class JLabel representing the card equal to method call getLabel() on class CardUi iii. Comment out the call to method setText() on the instance of class JLabel |
||
| HumanPlayerUi.java | 1. Update the class to add the following member variables
1. CardUi cardUi; |
|
| 2. Update method displayCards() to do the following
a. In the for loop i. Instantiate the instance of class CardUi passing as arguments 1. The instance of class Card in the player’s hand at the looping variable’s index 2. The instance of class JButton created inside the for loop ii. Set local variable of class JButton representing the card equal to method call getButton() on class CardUi iii. Comment out the call to method setText() on the instance of class JButton |
||
| CardUi.java | 1. Add member variables
a. Card card; b. ImageIcon imageIcon; c. JButton button; d. JLabel label; e. int position; |
|
| 2. Generate getters for member variables
a. Of class JButton b. Of class JLabel |
||
| 3. Write a custom constructor that do the following
a. Receives two parameters i. Class Card ii. Class JButton b. Set member variable of class Card to the passed parameter c. Set member variable of class JButton to the passed parameter d. Call method selectFrontImage() |
||
| 4. Write a custom constructor that does the following
a. Receives three parameters i. Class Card ii. Class JLabel iii. Int b. Set member variable of class Card to the passed parameter c. Set member variable of class JLabel to the passed parameter d. Set member variable of primitive data type int to the passed parameter e. Based on the position of the player call method selectVerticalBackImage() or selectHorizontalBackImage() |
||
| 5. Write a custom constructor that does the following
a. Received one parameter of class JLabel b. Set member variable of class JLabel to the passed parameter c. Calls method selectHorizontalBackImage() |
||
| 6. Write method selectFrontImage() to do the following
a. Instantiate an instance of class String to represent the file name of the image file set equal to explicit text “../images/” b. Write a switch statement that evaluates the face of the instance of class Card i. Based on the naming convention of your image files, concatenate to the String instantiated in step a with the appropriate value ii. For example, I named my files as such “AceHearts”, “AceEuchre”, “AceDiamonds”, “AceClubs” iii. Therefore, I concatenate to the String instance “../images/” the explicit text “Ace” c. Write a switch statement that evaluates the suit of the instance of class Card i. Based on the naming convention of your image files, concatenate to the String instantiated in step a with the appropriate value d. Concatenate the explicit file extension to the String instance that represents the filename based on your naming convention, the String instance should look something like “../images/AceClubs.png” when finished e. Instantiate an instance of class URL set equal to the static method call getClass().getResource() passing the String instance as an argument f. Using exception handling (i.e. in a try block) i. Check if the instance of class URL is not null 1. If true, Instantiate the member variable of class ImageIcon passing the instance of class URL as an argument 2. Instantiate the member variable of class JButton passing the instance of class ImageIcon as an argument g. In the catch block i. Output an error message that the resource if not found ii. Set the instance of class ImageIcon equal to null |
||
| 7. Write method selectVerticalBackImage() to do the following
a. Instantiate an instance of class String set to explicit text “../images/backVertical.jpg” or whatever you named the back image of the card b. Instantiate an instance of class URL set equal to the static method call getClass().getResource() passing the String instance as an argument c. Using exception handling (i.e. in a try block) i. Check if the instance of class URL is not null 1. If true, Instantiate the member variable of class ImageIcon passing the instance of class URL as an argument 2. Instantiate the member variable of class JLabel passing the instance of class ImageIcon as an argument d. In the catch block i. Output an error message that the resource if not found e. Set the instance of class ImageIcon equal to null |
||
| 8. Write method selectHorizontalBackImage() to do the following
a. Instantiate an instance of class String set to explicit text “../images/backHorizontal.jpg” or whatever you named the back image of the card b. Instantiate an instance of class URL set equal to the static method call getClass().getResource() passing the String instance as an argument c. Using exception handling (i.e. in a try block) i. Check if the instance of class URL is not null 1. If true, Instantiate the member variable of class ImageIcon passing the instance of class URL as an argument 2. Instantiate the member variable of class JLabel passing the instance of class ImageIcon as an argument d. In the catch block i. Output an error message that the resource if not found ii. Set the instance of class ImageIcon equal to null |
||
| Euchre application | ||
| Test Cases | Test Cases pass | |
| Source compiles with no errors | ||
| Source runs with no errors | ||
| Source includes comments | ||
| Total | ||
Perform the following test cases
| Test Cases | ||
| Action | Expected outcome | |
| Test Case 1 | Rregression Testing: Initial JOptionPane displays | JOptionPane is similar to figure 1 |
| Text Case 2 | Regression Testing: JOptionPane Prompts User Name | JOptionPane is similar to figure 2 |
| Test Case 3 | Euchre Initial UI displays | Game UI looks similar figure 3 where:
1. The human player’s cards show the appropriate image associated with each card in their hand 2. The AI players’ cards show a back image 3. The table has a place holder for each player when they play a card |
| Test Case 4 | Project view | Project view matches figure 4 |
Figure 1 Intro JOptionPane
Figure 2 Prompt for User’s Name
Figure 3 Euchre Initial UI
Figure 4 Project View





