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

  Java programming skills

Write a program that will play rock, paper, scissors against them, but since we are annoyed at this challenge, write it in such a way that it can never lose. However, it must be able to tie so that they dont get TOO suspicious. In your main, ask the ..

  Which is the correct statement for constructor implemention

In a multifile, object-oriented C++ project, which is the correct statement for the constructor implementation, given that the constructor is correctly defined in the class definition file?

  Write the code that reads an integer number called test

Write the code that reads values for a,b,c and displays their sum, repeating this process as long as none of the three values are negative.

  Show that the implementation of a queue

Show that the implementation of a queue that uses an extra array element as described in Section 14.1.3

  Investigating storage options

Dan is a small business owner who depends on his computer to keep track of customer and sales data. He is investigating storage options because it is critical for him to ensure that his data is safe in the event of a computer failure.

  A food distribution company ships fresh spinach

A food distribution company ships fresh spinach from its four packing plants to large East-coast cities. The shipping costs per crate, the supply and demand are shown in the table at the bottom of this page.

  Give a cfg for the set of all well formed strings

Give a CFG for the set of all well formed strings over {a,b,+,.,*, ?,?,(,) } that are well formed regular expressions over {a,b}

  Role of integrating business management cpabilities

How you see you role in integrating software, hardware, and business management cpabilities? What challenges do you anticipate encounting as head of of the IT management effort at Magnum?

  Developing channels of communication and collaboration

Plans for how your team will communicate and collaborate on this project for the purpose of choosing the best channels of communications for various audiences in the company

  Create a communication diagram for the scenarios

Create a communication diagram for the scenarios

  Structure and culture of contemporary organisations

The structure and culture of contemporary organisations Focused Debate Collapse -  Explain why the particular thing you learned was important for your long-term success in that organisation.

  How can objectives be used as a filter system

How can objectives be used as a filter system through which the organizational purpose is transferred into comprehensive outcomes against which to measure performance?

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