Display Cards on the Deck
Create four foundation stacks with all 52 cards divided in it.
Creating a CardStack
class
The Baker’s Dozen card game is going to need to arrange cards in stacks. Some stacks, like the foundation piles, will have cards placed directly on top of each other. Others, like the board, will have cards stacked in a column, overlapping each other.
- Create a new class called
CardStack
in thebakersDozen
package, with the default superclassObject
and with no stub code. - Add a private
ArrayList
of typeCard
instance variable calledcards
, initialized by callingArrayList
's constructor. - Create private integer instance variables called
stackX
,stackY
, andoverlap
, each with an initial value of0
. - Create a constructor with three parameters, integers called
stackX
,stackY
, andoverlap
. In the constructor, assign the parameter values ofstackX
,stackY
, andoverlap
to their corresponding instance variables. (Hint: usethis
.)
package bakersdozen;
import java.util.ArrayList;
public class CardStack {
_________ cards = _______________;
_________ stackX = _____;
_________ stackY = _____;
_________ overlap = _____;
_________ CardStack(___________________) {
______.stackX = _______;
______.stackY = _______;
______.overlap = _______;
}
}
Get hands-on with 1200+ tech skills courses.