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

  Main differences between client-server

What are the main differences between client/server and web applications? Give your opinion on what Thomas L. Friedman is referring to with the words, "Now the real IT revolution is about to begin." Discuss how the beginning, referred to by Friedm..

  Explaining minor or major virus threats

Write down two recent virus threats, are they minor or major threats? What software would you utilize to remove these threats?

  Represent processor demand in the time interval

Let the function D[i, j] represent processor demand in the time interval (i, j). Prove the following theorem.

  How can you adjust a heap if a single value changes

How can you adjust a heap if a single value changes?

  What is the minimum value of p necessary to meet your goal

What is the minimum value of p necessary to meet your goal.

  Important task for a systems administrator

An important task for a systems administrator is explaining how to troubleshoot common computer issues new employees encounter.

  Find the limiting value of the first local minimum

Derive, from first principles, the answers to parts (a) and (b). (Hint: Look up in a standard integral table the sine integral function.)

  Create a program called tokens.java

Create a program called Tokens.java that will receive any text file name as a command line argument and display all the unique tokens (separated by space/s) there are in the given text file

  Technical standards in a policy definition document

For each of the seven domains of a typical IT infrastructure, describe a policy you would write and implement for each domain.

  Smallest address size that can be used

A memory is byte addressable and has a total size of 16,384 bytes. What is the smallest address size that can be used for this memory?

  A photo-sharing startup offers

A photo-sharing startup offers the following service. A client may upload any number N of photos and the server will compare each of the N pairs of photos with their proprietary image matching algorithms to see if there is any person that is in both ..

  What is benchmarking and problem analysis with all its steps

What is Benchmarking and Problem analysis with all its steps.

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