Question
Create a Pile class that contains no more than five cards some face down, and some face up. Implement the following methods: constructors void addCardFaceDown(
Create a Pile class that contains no more than five cards some face down, and some face up. Implement the following methods: constructors void addCardFaceDown( Card card)Overview You are to write a program that simulates playing the solitaire card game Clock. Part 1 - Required Classes Create a Card class that can represent each of the 52 playing cards: Ace, 2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, King in each of the four suits: Spades, Hearts, Diamonds, and Clubs. Implement the following methods: constructors getSuit() getValue() String toString(): to print, e.g., 10 of Hearts or Queen of Diamonds or Ace of SpadesUpdate: We are thinking that printing cards more compactly -- e.g., 10H or QD or AS -- i.e. a one (or two) character value, followed by a one-character suit -- will make both debugging. Create a Deck class that represents a standard deck of 52 playing cards. Implement the following methods: constructors void shuffle(): randomly interchanges cards in the deck to simulate shuffling Card dealCard() int cardsLeft() String toString(): iterate through your deck array, printing all the cards, in a way thats convenient to check what cards are there; we think itll be best to print all the cards on one line (or print them on four lines, if you want to get fancy); for cards that have been dealt, either dont print them, or print them separately, labeled as dealt
Create a Pile class that contains no more than five cards some face down, and some face up. Implement the following methods: constructors void addCardFaceDown( Card card) Card removeCard() - removes and returns the top face down card (null if there are none) int getNumberOfFaceDown() void addCardFaceUp( Card card) int getNumberOfFaceUp() String toString() - print the cards in the Pile; print the contents of a pile on one or two lines; label the portion of the pile thats face up versus face down
Part 2 - The Clock Solitaire Game
Implement the Clock Solitaire Game simulation, with all the following capabilities. We strongly suggest you dont ignore handling command line arguments, as this feature is simply to implement, and will be a great help in your debugging process, and in our grading. Name your primary class -- the one with the main() method -- ClockSolitaire.
Command-Line Arguments Your program will accept two command line arguments. (These arguments are optional, and your program will use the default values if the argument(s) are not specified. And, implementing handling of command line arguments is not optional.) 1. Print level - one of the following three values:
a. verbose b. normal (the default) c.
silent2. Number of games to play (default: 1)
Setup Tasks create thirteen Piles
these should be stored in an array of Piles (rather than thirteen discrete variables)
create and shuffle a Deck of Cards deal out the deck to populate (initialize) the thirteen Piles with four face-down cards each You may deal one card for each of the thirteen Piles, and then a second card,
and so on or, you may deal four cards to fill the first Pile, four for the second Pile, and so on print the thirteen Piles -- the game board (this will mainly uses Pile.toString() ), if the print level is not silent; label each pile with its clock position; for simplicity, you can print one pile per line (you can get more creative, if you like) print the score: the number of Piles with at least one face-down card, if the print level is not silent; note a game is won when the score is zero
this will be 13 at the beginning of each game
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