Answered step by step
Verified Expert Solution
Link Copied!

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 0: 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 5,10,3,15,2 and player two has cards 1,8,17,0,4, the game would be played as follows:
Round 1:
Player 1: 5, Player 2: 1, Player 1 wins!
Round 2:
Player 1: 10, Player 2: 8, Player 1 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 5 points, you can add this functionality.
For example: a player's cards can be stored in an array such as: int[] player1={5,10,3,15,2};
For another extra 5 points, make the game more flexible, so that each player can have 1 to 26 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Next Generation Databases NoSQLand Big Data

Authors: Guy Harrison

1st Edition

1484213300, 978-1484213308

More Books

Students also viewed these Databases questions

Question

=+d) Explain what 95% confidence means in this context.

Answered: 1 week ago

Question

2 What are the advantages and disadvantages of job evaluation?

Answered: 1 week ago

Question

1 Name three approaches to job evaluation.

Answered: 1 week ago