In the card game War, a deck of playing cards is divided between two players. Each player exposed a card; the player whose card has the higher value wins possession of both exposed cards. Create a console-based computerized game of War named WardCardGame in which a standard 52-card deck is randomly divided between two players, one of which is the computer. Reveal one card for the computer and one card for the player at a time. Award two points for the player whose card has the higher value. (For this game, the king is the highest card, followed y the queen and jack, then the numbers 10 down to 2, and finally the ace.) if the computer and player expose cards with equal values in the same turn, award one point to each. At the end of game, all 52 cards should have been played only once, and the sum of the player’s and computer’s score will be 52. Use an array of 52 integers to store unique values for each- card. Write a method name FillDeck() that places 52 unique values into this array. Write another method named SelectCard() that you call twice on each deal to select a unique card for each player, with no repetition of cards in 26 deals. (To pause the play between each dealt hand, use a call to ReadLine().) Create a GUI version of the War card game described in above, and name it WarCardGameGUI. Let the user click a button to deal the cards, then make that button invisible and expose a Play button. Each time the user clicks Play, a pair of cards is revealed. To keep the Frame size reasonable, you might want to erase the output label’s contents every four hands or so.
Control structures
Control structures are block of statements that analyze the value of variables and determine the flow of execution based on those values. When a program is running, the CPU executes the code line by line. After sometime, the program reaches the point where it has to make a decision on whether it has to go to another part of the code or repeat execution of certain part of the code. These results affect the flow of the program's code and these are called control structures.
Switch Statement
The switch statement is a key feature that is used by the programmers a lot in the world of programming and coding, as well as in information technology in general. The switch statement is a selection control mechanism that allows the variable value to change the order of the individual statements in the software execution via search.
In the card game War, a deck of playing cards is divided between two players. Each player exposed
a card; the player whose card has the higher value wins possession of both exposed cards. Create
a console-based computerized game of War named WardCardGame in which a standard 52-card
deck is randomly divided between two players, one of which is the computer. Reveal one card for
the computer and one card for the player at a time. Award two points for the player whose card
has the higher value. (For this game, the king is the highest card, followed y the queen and jack,
then the numbers 10 down to 2, and finally the ace.) if the computer and player expose cards with
equal values in the same turn, award one point to each. At the end of game, all 52 cards should
have been played only once, and the sum of the player’s and computer’s score will be 52.
Use an array of 52 integers to store unique values for each- card. Write a method name FillDeck()
that places 52 unique values into this array. Write another method named SelectCard() that you
call twice on each deal to select a unique card for each player, with no repetition of cards in 26
deals. (To pause the play between each dealt hand, use a call to ReadLine().)
Create a GUI version of the War card game described in above, and name it WarCardGameGUI.
Let the user click a button to deal the cards, then make that button invisible and expose a Play
button. Each time the user clicks Play, a pair of cards is revealed. To keep the Frame size
reasonable, you might want to erase the output label’s contents every four hands or so.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps