Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Hide Assignment Information Instructions Assignment 0 : Arrays Review communication iconWhat to do & Why? As we get ready to study various data structures and
Hide Assignment Information
Instructions
Assignment : Arrays Review
communication iconWhat to do & Why?
As we get ready to study various data structures and algorithms this semester, we review the most basic data structure you already know about! the array. There's only two ways to store things in computers next to each other in contiguous memory or scattered throughout memory. Arrays store things in contiguous memory, and there's some implications related to that immutable size and random access. Each of these implications are directly related to how you write programs you must declare the size of arrays for memory allocation, and are able to directly access any element in an array using an index.
info iconHow to do it
In this assessment, write a simple card game similar to the classic card game "war." Each card will be represented using an integer stored inside an array. Two players will receive five cards each, and then the players will compete for five rounds to see who has the higher card during each turn.
For example, if player one has cards and player two has cards the game would be played as follows:
Round :
Player : Player : Player wins!
Round :
Player : Player : Player wins!
and so on
At the end of the game, the player who won the most rounds is the winner.
Notes:
You can hardcode the values for the cards for each player. You do not have to write any logic for randomizing the cards or dealing cards. However, for an extra points, you can add this functionality.
For example: a player's cards can be stored in an array such as: int player;
For another extra points, make the game more flexible, so that each player can have to cards the game should prompt the user for the number of cards per player at the beginning of the program
Do NOT use the ArrayList class for this assignment.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started