CSC160 Assignment 5 solved

$30.00

Original Work ?

Download Details:

  • Name: AssignmentFive-ch9xzw.zip
  • Type: zip
  • Size: 90.23 KB

Category: Tag: You will Instantly receive a download link upon Payment||Click Original Work Button for Custom work

Description

5/5 - (1 vote)

Write a complete program that implements the functionality of a deck of cards. In writing your program, use the provided DeckDriver and Card classes shown below. Write your own Deck class so that it works in conjunction with the two given classes. Use anonymous objects where appropriate.

Deck class details:

  • Use an ArrayList to store Card objects.

  • Deck constructor: The Deck constructor should initialize your ArrayList with the 52 cards found in a standard deck. Each card is a Card object. Each Card object contains two instance variables – num and suit. Study the Card class definition below for details.

  • dealCard: This method removes the highest-indexed card in the ArrayList and returns it. In general, a method should not do more than what it’s supposed to do. Thus, dealCard should not print anything.

  • toString: This method returns the deck’s contents using the format shown in the output session. In particular, note that toString should insert a newline after every fifth card. Hint: In coming up with a return value, use a String local variable. As you generate card values and newlines, concatenate those items to your local variable using the += operator.

Write your code such that the following classes produce the output shown in the subsequent output.