QuestionQuestion

Assignments 1
Over the course of the next couple of chapters, we are going to work on building a functional deck of cards that could be used in many different games.
Write a program named Display4Cards to display 4 random cards in a grid pane.
• Your stage title should display "4 Cards"
• All 4 cards should be distinct and displayed randomly. (each time you run it, the cards should be different and there is only 1 of each card in your deck)
• The easiest way to build your deck is with an integer array list. You can then use the built in "shuffle" method in the java.util.Collections library.
• Make certain your window is big enough to display your title
• Change the Background color of your pane

Assignment 2
Modify your "Display 4 cards" program to be a "Deal Cards" program.
Your program should prompt the user for how many cards to display and then display them.
• Your stage title should display "Cards Dealt"
• All cards should be distinct and displayed randomly. (each time you run it, the cards should be different and there is only 1 of each card in your deck)
• The easiest way to build your deck is with an integer array list. You can then use the built in "shuffle" method in the java.util.Collections library.
• Make certain your window is big enough to display your title. Your user input can be used to set-up the values on your grid.
• You should display no more than 7 cards per row.
• Change the Background color of your pane.

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

* Assignment 1 Program
*/
public class Display4Cards extends Application {
   
    @Override
    public void start(Stage stage) throws Exception {
      
       ArrayList<Integer> cards = new ArrayList<Integer>();
       for (int i = 1; i <= 52; i++)
            cards.add(i);
       Collections.shuffle(cards);
      
       stage.setTitle("4 Cards");
      
       Image image1 = new Image("File:cards/" + cards.remove(0) + ".png");
       Image image2 = new Image("File:cards/" + cards.remove(0) + ".png");
       Image image3 = new Image("File:cards/" + cards.remove(0) + ".png");
       Image image4 = new Image("File:cards/" + cards.remove(0) + ".png");

       GridPane gridPane = new GridPane();

       gridPane.add(new ImageView(image1), 1, 1, 1, 1);
       gridPane.add(new ImageView(image2), 2, 1, 1, 1);
       gridPane.add(new ImageView...

By purchasing this solution you'll be able to access the following files:
Solution.zip.

$50.00
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats