support@qualityresearchpapers.com

+1(316)4441378

+44-141-628-6690

Our Services

Handheld Solitaire

Handheld Solitaire
Handheld Solitaire requires no table, has simple rules, and is easily learned and played. It is played with a traditional 52 card deck of 4 suits (hearts, clubs, diamonds, and spades) and 13 ranks from ace (1) to king (13). Jokers are not included. The deck (face down) is held in one hand, while the actual hand of cards to be played is placed face up on top of the deck. This leaves the other hand free for dealing and discarding. The rules of play are as follows:
    Shuffle the deck, then hold it face-down in one hand.
    While the deck is not empty:
    Deal a single card from the top of the deck into the top of the playing hand
    While a match occurs in the playing hand between the top card and the card 3 back from it, either in rank or suit, collapse the hand using the following rules:
    If the ranks match, all 4 top cards of the hand are discarded. For example, if the cards are: 2S 6S 9C 2H , we would be comparing the last card dealt, 2S, to the card which is three back from it, 2H. Because the values match, we would discard all four cards.
    If the suits match, only the middle 2 (of the top 4) cards of the hand are discarded. For example, if the cards are: JH 3S 5C 7H , we would be comparing the last card dealt, JH, to the card which is three back from it, 7H. Because the suits match, we would discard the middle to cared (3S and 3C) and be left with JH 7H .
    The final score is the number of cards left in the hand at the end of the game.
There are several requirements in designing this project.
    A single card should be represented by a Card class. A card should be represented by a value (int) and a suit (char), and must include a pointer to a Card named nextCard as one of the private data members. Implement appropriate getter and setter functions and two constructors (one for default values and one with explicit parameters). It should also have a print() function described by the following bullet. Use Card.h and Card.cpp files to develop the class.
o    The print function should print the value and suit of the card in two characters. Thus, print the numerical value. However, if the value is 1, print A (for [A]ce); if it is 10, print T (for [T]en); if it is 11, print J (for [J]ack); if it is 12, print Q (for [Q]ueen); if it is 13, print K (for [K]ing). Follow this by the character representing the suit ([S]pades, [C]lubs, [H]earts, [D]iamonds), The following give some examples of a card, followed by how it should be printed:
    Ace of Hearts would be printed as: AH
    10 of Diamonds would be printed as: TD
    5 of Clubs would be printed as: 5C
    A deck and a playing hand of cards should each be represented by a CardLL class containing two private data members: a length variable to store the number of items in the CardLL object and a Card pointer named top. This will be a pointer to a linked list of Card objects (Cards will be the nodes of the linked list). Implement the class using CardLL.h and CardLL.cpp files. The functions to implement for this class are as follows.
o    CardLL (default constructor). The function sets the list pointer to be NULL and the length to be zero.
o    ~CardLL (destructor). Deletes each item from the list, one by one.
o    insertAtTop(suit, value). The function inserts a given card at the top of the list.
o    getCardAt(pos). This function will return a Card pointer which points to the card at the given position. If the position doesnt exist in the list, just return NULL.
o    removeCardAt(pos). This function will remove the card at the given position, returning true if successful. If the position outside the bounds of the list, return false.
o    getLength(). Returns the length of the list.
o    isEmpty(). Returns true if the list is empty; false otherwise.
o    print(). Prints the word top: followed by each card in the linked list, all on one line. (Utilize the Card print() function to aid with printing each individual card.
o    shuffle(). This will randomly shuffle a list of cards using the Fisher-Yates shuffle algorithm as follows (implement this function last):
    Use a while loop to walk through each Card in the list. Also within the loop:
    Get a random number between 0 and length 1
    Use getCardAt to get the card at that position
    Swap the card at the walk position with the card at the position random position. Just swap the suit and the value, not the nextCard pointer!
    Notes about random numbers:
    include the cstdlib and ctime files.
    place the following line as the first line of main(): 
    srand(time(NULL));
    In your CardLL classs shuffle() function, use rand() (with the modulus operator) to generate a random number in the appropriate range. Click here for an example of using rand()or consult page 274-275 of your textbook.
If there are additional class member functions that you would like to implement to ease the programming, you are allowed to do so. However, they should be clearly documented where necessary and should follow a structured object-oriented design approach.
Game play should be simulated in a client file called HHSolitaire.cpp. Follow the directions on the first page for the way the game is played. Represent the Deck and the Hand (playing hand) using a CardLL object for each. Use comments and functions to aid in the readability of your code. One function in particular to implement is populateDeck, which handles creating a new complete deck of 52 playing cards as follows (wrapped onto two lines below):
AD 2D 3D 4D 5D 6D 7D 8D 9D TD JD QD KD AC 2C 3C 4C 5C 6C 7C 8C 9C TC JC QC KC AH 2H 3H 4H 5H 6H 7H 8H 9H TH JH QH KH AS 2S 3S 4S 5S 6S 7S 8S 9S TS JS QS KS
Hint: To create the deck, use a nested for loop (one for the values [1-13] and one for the suits [D, C, H, S]) to generate the suits and values for the cards as you insert them into the deck.
    *Game play in this game, by its very nature, is deterministic. Thus, the entire game play can be printed to the output all at once. To give the program more of a game feel, though, you can use getchar() before each call to Hand.print() in main() to force the user to press the Enter key between each new card being played. Include stdio.h library in order to use this. This part should be saved until the very end of all testing!
Start early. I cannot emphasize this enough. This project will once again challenge your logical and critical thinking skills. Think of the design (structure, flow, logic sequence) of the program before implementing it. Learn from the previous projects. I will briefly reiterate the approach you should take below:
    Write down/draw out, on paper, how the overall design of the program should look. Getting your thoughts down on paper will help you organize/refine your approach and get a better grasp of how the individual components should fit together.
    Implement your program as empty function stubs at first and develop incrementally, testing one piece at a time before moving on. Building your program slowly from the ground up will allow you to foresee and prevent potential problems later on in development.
    Test many different input cases as you are developing your program and even once you feel that the program is complete. A good strategy is to try to break your program with a variety of different test casesit is much better for you to find a software mistake and fix it early than to have the final product fail the end user(s) because you didnt test adequately.
Testing: Test the program in steps. Build the Card and CardLL classes and verify that adding and deleting cards from the list works as you expect. Then start adding in individual elements of game play, incrementally. You will likely get segmentation faults as you develop this program. These are frustrating. However, these are a lot easier to debug if you test your program little by little.
Submission: This project is worth 110 points and is due on Friday, March 27th before noon. Submission must include:
    An electronic turn-in through Canvas. The entire Visual Studio solution folder must be zipped in order to do this. To create a zipped folder, right-click the folder and select Send to -> Compressed (zipped) folder. Rename this folder Project3_firstname_lastname where firstname and lastname are replaced with your first and last name, respectively. Upload this zipped folder to the Project 2 assignment page. Make sure that the following files are included in your project:
    HHSolitaire.cpp
    CardLL.cpp
    CardLL.h
    Card.cpp
    Card.h
    A paper printout of your code, along with console outputs from at least 3 separate program runs.
Grading: The program will be graded along the following dimensions. Note that the values in brackets are percentages of the project grade. Point distributions will be weighted accordingly.
    [20] Card implementation
    [35] CardLL implementation
    [35] HHSolitaire implementation
    [20] Overall quality of program design, code structure/readability, and user interaction
For the final bullet, ensure that the program files contain header comments, formatted as required by the CSCI documentation guidelines. Documentation (commenting) is used to illustrate major sections or unclear sections of code as well. Program design should clearly convey intent, especially focusing on proper use of variable names, whitespace, alignment and indentation

Make sure that the file names are correct, that your program contains no syntax errors, and that all of the code compiles. Programs that do not compile will receive an automatic 20 point deduction (20% of the project grade). This will be in addition to any deductions on the items listed above.

If you are unable to decipher a compiler error in your program, its better to comment out that section of code so that the program compiles without error. This way I can see that it was at least attempted and you may receive partial points for that section of code. In addition to the commented out section, write a detailed explanation of what you think the error may be, and the steps you tried in order to fix the error.

Academic Honesty: I expect you to maintain a high ethical standard when developing your programs. Students are bound by the academic honesty policies of the department, college, and university. Direct collaboration with others on this project is not permitted, and helping generate specific lines or chunks of code is strictly prohibited. General design strategies of the software program may be discussed at a high level.

Output: You may use the following as a guide to what your output should look like.

Top: 8C
Top: 9C 8C
Top: 4H 9C 8C
Top: 2S 4H 9C 8C
Top: TS 2S 4H 9C 8C
Top: 7H TS 2S 4H 9C 8C
Suit Match! Removing: TS 2S

Top: 7H 4H 9C 8C
Top: 7S 7H 4H 9C 8C
Top: KH 7S 7H 4H 9C 8C
Suit Match! Removing: 7S 7H

Top: KH 4H 9C 8C
Top: 9H KH 4H 9C 8C
Number Match! Removing: 9H KH 4H 9C

Top: 8C
Top: 8D 8C
Top: 3C 8D 8C
Top: QD 3C 8D 8C
Top: 4D QD 3C 8D 8C
Suit Match! Removing: QD 3C

Top: 4D 8D 8C
Top: 6C 4D 8D 8C
Suit Match! Removing: 4D 8D

Top: 6C 8C
Top: 2D 6C 8C
Top: AS 2D 6C 8C
Top: 9D AS 2D 6C 8C
Top: JS 9D AS 2D 6C 8C
Top: AD JS 9D AS 2D 6C 8C
Number Match! Removing: AD JS 9D AS

Top: 2D 6C 8C
Top: JC 2D 6C 8C
Suit Match! Removing: 2D 6C
Top: JC 8C
Top: AC JC 8C
Top: 4C AC JC 8C
Suit Match! Removing: AC JC

Top: 4C 8C
Top: TH 4C 8C
Top: 6H TH 4C 8C
Top: 5D 6H TH 4C 8C
Top: JH 5D 6H TH 4C 8C
Suit Match! Removing: 5D 6H

Top: JH TH 4C 8C
Top: 7C JH TH 4C 8C
Suit Match! Removing: JH TH

Top: 7C 4C 8C
Top: 4S 7C 4C 8C
Top: AH 4S 7C 4C 8C
Top: KC AH 4S 7C 4C 8C
Suit Match! Removing: AH 4S

Top: KC 7C 4C 8C
Suit Match! Removing: 7C 4C

Top: KC 8C
Top: 5H KC 8C
Top: 2H 5H KC 8C
Top: QC 2H 5H KC 8C
Suit Match! Removing: 2H 5H

Top: QC KC 8C
Top: TD QC KC 8C
Top: 3S TD QC KC 8C
Top: 5C 3S TD QC KC 8C
Suit Match! Removing: 3S TD

Top: 5C QC KC 8C
Suit Match! Removing: QC KC

Top: 5C 8C
Top: 8H 5C 8C
Top: KS 8H 5C 8C
Top: 2C KS 8H 5C 8C
Suit Match! Removing: KS 8H

Top: 2C 5C 8C
Top: 6D 2C 5C 8C
Top: 3H 6D 2C 5C 8C
Top: KD 3H 6D 2C 5C 8C
Top: 3D KD 3H 6D 2C 5C 8C
Suit Match! Removing: KD 3H

Top: 3D 6D 2C 5C 8C
Top: 7D 3D 6D 2C 5C 8C
Top: JD 7D 3D 6D 2C 5C 8C
Suit Match! Removing: 7D 3D

Top: JD 6D 2C 5C 8C
Top: TC JD 6D 2C 5C 8C
Suit Match! Removing: JD 6D

Top: TC 2C 5C 8C
Suit Match! Removing: 2C 5C

Top: TC 8C
Top: 5S TC 8C
Top: QH 5S TC 8C
Top: 8S QH 5S TC 8C
Top: 9S 8S QH 5S TC 8C
Suit Match! Removing: 8S QH

Top: 9S 5S TC 8C
Top: QS 9S 5S TC 8C
Top: 6S QS 9S 5S TC 8C
Suit Match! Removing: QS 9S

Top: 6S 5S TC 8C

Deck Empty! Printing leftover hand:

Top: 6S 5S TC 8C

 

You can place an order similar to this with us. You are assured of an authentic custom paper delivered within the given deadline besides our 24/7 customer support all through.

 

Latest completed orders:

Completed Orders
# Title Academic Level Subject Area # of Pages Paper Urgency
[order_calculator]
Copyright © 2016 Quality Research Papers All Rights Reserved