Question: I need help I am stuck and don't know how to proceed. What I have so far. Card Class ----------------- package PlayingCards; /** * @author

I need help I am stuck and don't know how to proceed.
What I have so far.
Card Class
-----------------
package PlayingCards;
/**
* @author ()
* @version (1/29/2020)
*/
public class Card
{
private int rank;
private char suit;
public Card(int rank, char suit)
{
if((rank >= 1 && rank
{
this.rank = rank;
this.suit = suit;
}
else
{
System.out.println("Error Invalid Choice");
}
}
public char getSuit()
{
return this.suit;
}
public int getRank()
{
return this.rank;
}
public void display()
{
switch (suit)
{
case 2:
System.out.println(this.rank + this.suit);
break;
case 3:
System.out.println(this.rank + this.suit);
break;
case 4:
System.out.println(this.rank + this.suit);
break;
case 5:
System.out.println(this.rank + this.suit);
break;
case 6:
System.out.println(this.rank + this.suit);
break;
case 7:
System.out.println(this.rank + this.suit);
break;
case 8:
System.out.println(this.rank + this.suit);
break;
case 9:
System.out.println(this.rank + this.suit);
break;
case 'T':
System.out.println(this.rank + this.suit);
break;
case 'A':
System.out.println(this.rank + this.suit);
break;
case 'J':
System.out.println(this.rank + this.suit);
break;
case 'Q':
System.out.println(this.rank + this.suit);
break;
case 'K':
System.out.println(this.rank + this.suit);
break;
}
}
}
DeckOfCards Class
----------------------------
package PlayingCards;
import java.util.*;
public class DeckOfCards
{
private ArrayList
public DeckOfCards()
{
cards = new ArrayList
}
public Card shuffle() // *for loop and index*
{
Random generator = new Random();
int index = generator.nextInt(cards.size());
return cards.remove(index);
}
public void print()
{
System.out.println(cards);
}
public void remove(int rank)
{
Iterator
int s;
while (it.hasNext())
{
s = it.next();
if (s == rank)
{
it.remove();
}
}
}
}
1. Write a class called Card that has the following: a. A field for the rank. This will be an integer value from 1 to 13 where Ace = 1 and King = 13. A field for the suit. This can be a single character where clubs = 'c', diamonds = 'd', hearts = 'h' and spades = 's'. C. A constructor that takes two parameters and initializes the Card object to these values. d. A getter (accessor method) and a setter (mutator method) for each field. A display method to display the cards value. (Hint: Use a switch statement)Use the following format: i. For number ranks 2 through 9, use the number. For example, 3 of hearts would be displayed as 3h. ii. For an ace use the letter capital A. For example the ace of spades would be displayed as As. iii. For the rank of 10, use the capital letter T. For example the ten of diamonds would be displayed as Td. iv. For the ranks of Jack, Queen and King, use the first (capital) letter of the rank. For example, the Queen of clubs would be displayed as Qc. 2. Write a class called DeckOfCards. This class should have the following: a. A field that is an ArrayList of Cards objects. b. A constructor to initialize the deck (in any order you like). C. A method to shuffle the deck of cards. You will do this by using a random number generator to select a card in the current deck, remove it from the current deck and add it to a new (initially empty) deck you have created. Then copy it back to the original deck (Hint: you can use a for loop to do this). d. A method that can print the entire current deck of cards, one card per line. e. A method that will remove all of the cards of a specified rank (Hint: Use a while loop with an Iterator to do this)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
