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.

  1. Create a new class called CardStack in the bakersDozen package, with the default superclass Object and with no stub code.
  2. Add a private ArrayList of type Card instance variable called cards, initialized by calling ArrayList's constructor.
  3. Create private integer instance variables called stackX, stackY, and overlap, each with an initial value of 0.
  4. Create a constructor with three parameters, integers called stackX, stackY, and overlap. In the constructor, assign the parameter values of stackX, stackY, and overlap to their corresponding instance variables. (Hint: use this.)
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.