Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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

ID: 3708065 • Letter: I

Question

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

HumanPlayerUi.java1. Create class HumanPlayerUi so it uses class JPanel as the superclass 2. Add member variables of type: a. HumanPlayer human; b. ArrayList cards 3. A custom constructor should be defined that receives a one parameter, data type class Player Set member variable of type class HumanPlayer to the parameter passed in of class Player using an explicit type cast a. b. Call method initComponentsO 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. setMinimumSizeO c. setPreferredSizeO 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 f. Call method displayCards a. Loop through the member variable of data type ArrayList axis 5. Write method displayCards to do the following containing elements of class JButton so there are 13 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'" v. vi. concatenated with the looping variable Add the JButton to the ArrayList Add the JButton to the JPanel

Explanation / Answer

import java.awt.Color;

import java.awt.Dimension;

import java.util.ArrayList;

import javax.swing.*;

//MainClass for GUI extends JPanel

public class HumanPlayerUI extends JPanel {

//HumanPlayer class must be your part of the code

HumanPlayer human;

ArrayList<JButton> cards;

//constructor with one argument . Also Player Class must be Super Class of HumanPlayer Class

public HumanPlayerUI(Player player)

{

//typeCasting Player object to HumanPlayer

human=(HumanPlayer)player;

//calling initComponents

initComponents();

}

//initComponent definition

public void initComponents()

{

//setting siz of Panler HumanPLayerUI

setMinimumSize(new Dimension(200,300));

setPreferredSize(new Dimension(500,700));

//instantiating arraylist

cards=new ArrayList<JButton>();

//set Panle layout to Box Layout for horizontal alignment

setLayout(new BoxLayout(this, BoxLayout.X_AXIS));

//calling displayCards method

displayCards();

}

void displayCards()

{

//instantiating 13 buttons

for(int i=0;i<13;i++)

{

JButton button=new JButton();

//button sizing

button.setSize(50, 40);

//setting button borders

button.setBorder(BorderFactory.createLineBorder(Color.BLACK, 4));

//setting button text

button.setText("Card "+i);

//adding button to the araaylist

cards.add(button);

//adding button to the Panel HumanPlayerUI

this.add(button);

}

}

}

NOTE:[The above answer is respect to your question's ask . Few Classes like HumanPlayer , Player definitions need to be in place , else it will give errors . Kindly provide the class details for HumanPlayer and Player classes for building the complete application ]

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote