Display the values of the player''s and computer''s cards

Assignment Help Basic Computer Science
Reference no: EM131096415

A standard deck of 52 playing cards holds cards with the values 1 through 13 representing Ace, 2 through 10, Jack, Queen, and King in each of four suits ("Clubs", "Diamonds", "Hearts", and "Spades"). Create an array so that all 52 card combinations are represented. Create a War card game that randomly selects two cards (one for the player and one for the computer) and declares a winner (or a tie) based on the numeric value of the two cards. The game should play for 26 rounds of War, dealing a full deck with no repeated cards. For this game, assume the cards' values are based on their numbers-that is, the lowest card is the Ace. Display the values of the player's and computer's cards, compare their values, and determine the winner. When all the cards in the deck are exhausted, display a count of the number of times the player wins, the number of times the computer wins, and the number of ties. Some hints:

• Start by creating an array of all 52 playing cards.

• Select a random number for the deck position of the player's first card and assign the card at that array position to the player.

• Move every higher-positioned card in the deck "down" one to fill in the gap. In other words, if the player's first random number is 49, select the card at position 49 (both the numeric value and the string), move the card that was in position 50 to position 49, and move the card that was in position 51 to position 50. Only 51 cards remain in the deck after the player's first card is dealt, so the available card array is smaller by one.

• In the same way, randomly select a card for the computer and "remove" the card from the deck.

Reference no: EM131096415

Questions Cloud

Is it sometimes necessary to sacrafice a few freedoms : Is it sometimes necessary to sacrafice a few freedoms to protect national security and to ensure the long-term viability of civil liberty?
Is a record of firearms sales sent to police : Is a record of firearms sales sent to police? Are certain firearms prohibited? What are the details of your state's concealed carry laws? Is there a hunter protection law? A range protection law? What do these mean?
Great effect on the global economy : Each individual will select a current topic that is of great effect on the global economy. You will develop a research paper topic revolving around a particular/current business topic and analyze its impact.
Design the logic for the game hangman : Design the logic for the game Hangman, in which the user guesses letters in a hidden word.
Display the values of the player''s and computer''s cards : compare their values, and determine the winner. When all the cards in the deck are exhausted, display a count of the number of times the player wins, the number of times the computer wins, and the number of ties
Represented as a list of nondefault column entries : (b) Compare the effectiveness of this representation with those given in Section 5.8. Consider both the savings in space and any increase or decrease in access time.
Weakness in light of the integrated approach : Analyze the organization in which you work in terms of its diversity management initiatives. Which diversity components dose your company currently implement? Not implement? What are your company's strengths and weakness in light of the integrated..
What is an ascetic ideal according to nietzsche : Distinguish between Master/Noble and Slave moralities in Nietzsche. How, and in what order, does each generate the concepts of good and bad? What is wrong with the slave morality according to Nietzsche? What does Nietzsche think is wrong with the ..
Develop an mrp for space age furniture company : Develop an MRP for Space Age Furniture Company using the information in the case including the production of sub-assemblies in lot sizes of 1,000 - Analyze the trade-off between overtime costs and inventory costs.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Investigate project management body of knowledge

Investigate Project Management Body of Knowledge (PMBoK). Write a report on one of knowledge areas. Describe the task of understanding potential threats

  Methods for information systems can become vulnerable

While word weakness seems to define it pretty well, there are a number of mthods that information systems can become vulnerable.

  Which alternative would now be the most profitable

Calculate the center line value and control limits for the X-bar chart.

  Briefly describe what the notion

Briefly describe what the notion of "normal operation" means to an executing computer program

  Why do you think plaintext supposed to be the first format

Why do you think plaintext is supposed to be the first format, even though implementations might find it easier to place plaintext after their native format?

  Analyze the key ways that entity relationship modeling helps

Analyze the key ways that entity relationship modeling helps database developers

  What are the trade-off s with this method

What are the trade-off s with this method?

  Write program take input and test scores

I need a program that allows me to... 1. Input students test scores(Tests, Quizzes, Classwork, and Homework) stored in dynamically declared arrays and PPS weights given to each score

  Design a function to determine the minimum value

Design a function to determine the minimum value in a set of 4 values

  Telecommunications-networking discussion

The TCP, UDP, and IP were designed to provide best-effort service without quality of service (QoS) guarantees. Today's multimedia applications are implemented using these protocols.

  Write a program that places the names in an array

The USPres.txt contains the names of the 44 U.S. presidents in the order in which they served. write a program that places the names in an array and displays all presidents for a requested range of numbers.

  Role of operating system

Title: Role of Operating System Answer these review questions based on operating systems:

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