Question: Phase 1 : Making Human's cards into buttons - All of this will only affect the human's hand of cards. We need to create a
Phase : Making Human's cards into buttons
All of this will only affect the human's hand of cards. We need to create a button for each of the cards that are in the human's pane.
Inside of the For loop where we are generating the Images and ImageViews, create a button for each and use the setGraphicImageView method to put the card graphic on the button.
Put the buttons into the human pane, instead of the ImageViews.
Since the cards will now be surrounded by a border to signify that they are now buttons, you will have to adjust the Insets for the human pane so that it all fits on the screen.
Here is a new private method that will help the start:
private void moveCardImage cTemp, Image hTemp, Pane pPane an image for the computer side and an image for the human side of the players pane middle in the playing area will be the arguments. You will need to clear the pane using getChildrenclear and then put the images into the playedImages array and convert them to ImageViews. These along with the labels should be added to the pPane. Several of those lines of code can simply be moved from the start method.
Next it is time to use the setOnAction event and call the method, moveCardImage Image, Pane In the for loop where the human images and buttons are being created, we will send it the image for the human on that round of k as well as a random card for the computer player. In order for these images to be sent, we will have to create some temporary Image variables and mark them final so that setOnAction will accept them. We will call moveCard anytime we click the mouse on one of the cards as well as during the initial run through of start If we set the computer number inside of the setOnAction then we will get a new card each time we click on a given card image button. Here is some code to help you: Next it is time to use the setOnAction event and call the method, moveCardImage Image, Pane In the for loop where the human images and buttons are being created, we will send it the image for the human on that round of k as well as a random card for the computer player. In order for these images to be sent, we will have to create some temporary Image variables and mark them final so that setOnAction will accept them. We will call moveCard anytime we click the mouse on one of the cards as well as during the initial run through of start If we set the computer number inside of the setOnAction then we will get a new card each time we click on a given card image button. Here is some code to help you:
final Image hTemp
humanBtnksetOnActione
final Image cTemp
moveCard;
Of course in order to use the pPane early, you will have to move its declaration up sooner, prior to the start method.
For the initial run of start make a call to moveCard just before you call setTop setCenter and setBottom Put in a couple of Aces for the start.
Here is a how it could look after you click on one of the cards. The clicked card will appear on the right side and a random card will appear on the left for the computer. Be sure to include the GUICard, CardIdentity, and Card classes
The best way to submit your code so that I can run it would be to remove the keyword "public" from in front of all classes that are not the main class, Foothill. Additionally, put all of the imports at the top of the program. Lastly, comment out all of the output at the bottom so that it will not be looked at by the IDE. I will then be able to copy, paste and run your code easily.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
