Question: Object Oriented Programming (java) Create the following classes in a project: Card Class (represents a playing card) Data : // Value 1 through 14 representing

Object Oriented Programming (java)

Create the following classes in a project:

Card Class (represents a playing card)

Data:

// Value 1 through 14 representing ranks of cards: 1: Ace,

// 11: Jack, 12: Queen, 13: King. Others are numerical

// values of cards

private int rank;

// suits of the cards: Hearts, Diamonds, Clubs, Spades

private String suit;

Methods:

// constructor which takes a rank and suit as parameters

// and sets the private data

public Card (int r, String s)

// prints the card in the form: King of Hearts

public void print ()

// returns the rank of the card

public int getRank ()

// returns the suit of the card

public String getSuit ()

Deck Class (represents a deck of 52 cards)

Data:

// array of cards

private Card [] deck;

Methods:

// constructor populates the deck with 52 cards

public Deck ()

// prints a deck, one card per line

public void print ()

// mixes the cards in a deck by making the given number of

// random swaps

public void mix (int swaps)

Cardsapp (main application class) does the following:

// create a deck of cards

// print the initial deck of cards

// call mix to swap two cards

// print the deck of cards

// call mix to swap 1000 cards

// print the deck of cards

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!