View the step-by-step solution to:

Before solving the question please watch the video it has most of the solution at 52 minute. This is the link for the video and try to use the

Before solving the question please watch the video it has most of the solution at 52 minute. This is the link for the video and try to use the material here make the solution simple do not use new stuff . (http://vimeo.com/groups/175885/videos/61771458 )
The question :
Create a Deck object. The Deck object should have a constructor that creates a deck of cards storing them in a Card[] field. The Deck object should also have an instance method named display, which displays the contents of the deck. Finally, it should have another instance method named shuffle, which when called, shuffles the deck of cards.
Your program should create an instance of the Deck class, display it in order using the display instance method of the Deck class and then call the shuffle method and display the now shuffled Deck.

Sample Code:
String[] theVals = "2,3,4,5,6,7,8,9,10,J,Q,K,A".split(",");
String[] theSuits ="Hearts,Diamonds,Clubs,Spades".split(",");
Card[] theDeck = new Card[52];
int pos = 0;
for(int i = 0; i < theVals.length; i++)
{
for(int j = 0; j < theSuits.length; j++)
{
theDeck[pos] = new Card(theSuits[j], theVals[i]);
pos++;
}
}



public class Card
{
//Fields
String suit;
String value;

//Constructors
Card(String suit, String value)
{
this.suit = suit;
this.value = value;
}

//method
void display()
{
System.out.println(this.value + " of " + this.suit);
}
}
Sign up to view the entire interaction

Top Answer

Attached is a detailed explanation... View the full answer

Sign up to view the full answer

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

-

Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question
Ask a homework question - tutors are online