Question
I need to make a junit test for this code that's called DeckTest It needs to test that there are 52 cards in a deck,
I need to make a junit test for this code that's called DeckTest It needs to test that there are 52 cards in a deck, 4 of each kind, and 13 of each suit. Then it needs to test that it actually makes a deck and test that it shuffles and test the public ArrayList getDeck() . The code below is the deck class and I just added the card class. Thank you
package code;
import java.util.ArrayList;
import java.util.Collections;
public class Deck {
private ArrayList deck;
public Deck() {
makeDeck();
shuffleDeck();
this.deck = getDeck();
}
public ArrayList getDeck() {
return this.deck;
}
public void makeDeck() {
ArrayList deck = new ArrayList<>();
for(int i = 1; i< 14; i++) {
Card card1 = new Card("HEARTS", i);
Card card2 = new Card("SPADES", i);
Card card3 = new Card("CLUBS", i);
Card card4 = new Card("DIAMONDS", i);
deck.add(card1);
deck.add(card2);
deck.add(card3);
deck.add(card4);
}
this.deck = deck;
}
public void shuffleDeck() {
Collections.shuffle(this.deck);
}
public static void main(String[] args) {
Deck deck = new Deck();
System.out.println(deck.getDeck());
}
}
package code;
public class Card {
private String suit;
private int rank;
public Card(String suit, int rank) {
this.rank = rank;
this.suit = suit;
}
public String getSuit() {
return suit;
}
public void setSuit(String suit) {
this.suit = suit;
}
public int getRank() {
return rank;
}
public void setRank(int rank) {
this.rank = rank;
}
@Override
public String toString() {
return "Card [suit=" + suit + ", rank=" + rank + "]";
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started