Question: public Card[] deal(int numCards)-- This method will remove the specified number of cards from the top of the deck and return them as an array.

public Card[] deal(int numCards)-- This method will remove the specified number of cards from the top of the deck and return them as an array. For example, if the parameter is 4, then the first four cards in the deck will be returned as an array of size 4. Important: The cards will be removed from the front of the "cards" array, not the back.

Hint: The "cards" array will need to be resized. Here is the idea:

Make a new array (call it "smaller") that is the same size as the current deck of cards minus the number of cards being dealt.

Copy the cards that are not being dealt from the original array into the new one.

Assign the instance variable "cards" so that it refers to the new array.

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!