Develop a method for shuffling

Assignment Help C/C++ Programming
Reference no: EM132263653

Programming Tasks

You should begin by reading the example code carefully. It contains some hints and comments on where to fill in the blanks.

The first step will be writing a function that displays the card. You can use the various bit fields as an index to an array of strings once extracted. The arrays are:

static char *suits[] = {"Hearts","Diamonds",
"Clubs","Spades"};

static char *values[]= {"Ace","Two","Three","Four",
"Five","Six","Seven","Eight",
"Nine","Ten","Jack","Queen", "King"};

static char *colour[]= {"Black","Red"};

You should print the card as "Ace of Hearts, is Red", with one card per line.

Test your function by creating cards individually and displaying them.

Once you can display cards you should then write a function that populates a deck (array of 52) with cards. The deck should be sorted in order by suit, that is Ace to King of hearts, then diamonds etc. With some clever arithmetic you can accomplish this in one pass of the deck. Print the deck once you have populated it.

Once you have a deck, develop a method for shuffling it. As a hint investigate the C standard library functions rand() and srand(). Shuffling involves mixing the cards up so that the order is random. Print the deck a second time and check that you have actually mixed up the deck.
Now that we have a working shuffling algorithm we are ready to play cards. To keep things reasonably simple we are going to simulate a simplified version of poker. In this game 5 hands of five cards are dealt. There is no swapping of cards and the winner is determined by who has the highest pair. A pair of cards are cards that have the same value e.g. the Ace of Hearts and the Ace of Spades are a pair. The number of pairs contained in a hand, three or four of a kinds have no bearing on the result. If none of the five hands contains a pair, or two hands contain the same highest pair, the game is considered drawn.

Although traditional poker has the Ace card being a turning point, that is it can be the low card or the high card, the cards in this game have a fixed order, as described in Table 2. This means that Aces are low and can be beaten by any other pair.

You should develop a program that implements this game. Additionally you should print each of the hands sorted in order of value, print the number of pairs in each hand and if there is at least 1 pair print the value of the highest pair. Once all five hands have been printed you should indicate if there was a winner and the value of the pair that won. If there was no winner you should indicate that the game was drawn.

Your hands should be stored in an array for ease of use and when sorting the hand you should investigate the C standard library function qsort(), which might make things easier for you.

Attachment:- Instructions.rar

Verified Expert

The task of the assignment is to develop a C program that plays the card game. Here the details of the Card are stored in the form of bit representation. The program requires no input, the cards are automatically generated and picked in the random order and the games are played and result are displayed to the user. The code is executed and the output is attached

Reference no: EM132263653

Questions Cloud

What was the value gained from the experience : What is the Leader currently reading for their professional development? What lessons are he/she is gaining from the book/article?
What are some of the problems that poor writing causes : What are some of the problems that poor writing causes for businesses? Please do not copy your answer from the article.
Identify categories of interventions that may improve : Explain workplace design, causes of performance gaps, staffing requirements, and identify categories of interventions that may improve performance.
Describe what is meant by fleeing to pure transcendence : How would an Existentialist sentence a convicted sex offender who pleaded the insanity defense due to drug addiction?
Develop a method for shuffling : 300698 Operating Systems Programming - Western Sydney University - Develop a program that implements game. Additionally you should print each of the hands
Explain the benefits and costs of keeping too much inventory : Explain the benefits and costs of keeping too much inventory. What is meant by the saying "Inventory = death"?
Identify which features of these two traditions you saw : While reading about any of the non-Western traditions, identify at least three traditions that you mentally compared to some theory in Western philosophy?
What is your definition of justice : Depending on your viewpoint, demonstrate which aspects of our current American society make it a just (or unjust) society?
Define the various components of the roles : Write a two- to three-page paper defining the various components of the roles and styles of Organizational Development Consultants (ODC).

Reviews

inf2263653

9/3/2019 2:04:22 AM

sample code with functions given just has to fill in code worth 10%. Make sure to deliver the work timely. Do not make it in a hurry go through the requirements carefully and deliver proper work.

len2263653

3/22/2019 4:42:32 AM

Speci1cations (80%) Program produces no results. The program works and produces the correct results and displays them correctly. It also meets most of the other speci1cations. The program works and meets all of the speci1cations.

len2263653

3/22/2019 4:42:18 AM

CRITERIA (Weighting) Readability (10%) Very good (75%) Excellent (100%) The code is fairly easy to read. The code is exceptionally well organized and very easy to follow. The documentation consists of embedded comment and some simple header documentation that is somewhat useful in understanding the code. The documentation is well written and clearly explains what the code is accomplishing and how.

len2263653

3/22/2019 4:42:06 AM

The following functionality items will be considered when evaluating how much of the specifi cation is implemented: • Printing a card • Filling the deck • Shu½ing the deck • Dealing the hands • Sorting the hands • Printing the hands Determining the number of pairs in a hand (Note: Three of a kind is one pair, and four of a kind is two pairs). • Determining the value of the highest pair in a hand

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd