Question: Learning about Arrays and Array lists. The Learning Goal for this exercise is to use and understand and know the difference between arrays and array

Learning about Arrays and Array lists.

The Learning Goal for this exercise is to use and understand and know the difference between arrays and array lists.

_Use at least one array defined in your code and two array lists defined by the operation of your code.

The array should be 52 elements and contain a representation of a standard deck of cards, in new deck order. (This is the order of a deck of cards new from the box.)

The 2 Array lists can be looked at as a draw deck and a hand deck. The original array is used to populate the draw deck before dealing.

  • Write and use a method to build a deck of cards where the array of cards is available in Main.
  • Use the clear screen method given in class, clear the screen when your program runs.(I am providing you an example code for clear screen method at the end of this page)
  • Use heading or titles and make the output look nice.
  • Back in Main, print out the cards, 4 per line, 1 suit per column. (using a loop might help)
  • Use the deck array to create an array list of cards and be able to shuffle those cards.
  • Print out the shuffled deck.
  • Deal out 5 cards to another array list and the remaining cards should be the draw pile. (you will be taking cards from one ArrayList and adding it to another.)
  • Print both the hand (5 cards) and the draw deck (47 cards).
  • Go Beyond modify the code to do something fresh. For example, deal 4 hands.

Example Code for clear screen method:

class myControl { public static void main(String[] args) { cls(); System.out.println("Howdy!"); sleep(5); cls(); System.out.println("Oh, I thought you were someone else."); beep(); sleep(2); System.out.println("GoodBye!"); }// end main public static void sleep(int s) { try { Thread.sleep(s*1000); } catch(Exception e) { System.out.println("not sleepy"); }//end try }//end sleep public static void beep() { System.out.println("\007"); }//end beep public static void cls() { if (System.getProperty("os.name").contains("Mac")) { System.out.println("\033[H\033[2J"); }else{ try { new ProcessBuilder("cmd","/c","cls").inheritIO().start().waitFor(); } catch(Exception e) { System.out.println("Error?"); }//end try }//end if }// cls }// end class

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!