Write a function that creates a 2-dimensional array

Assignment Help Other Subject
Reference no: EM132766792

Assignment

Instructions:
• Once you are done with the assignment, upload your source code to Omnivox as you would any exercise/assignment.

Overview

Connect 4 is a board game for 2 players in which the goal is to make a line, or column, or diagonal, of 4 colored discs in a grid of 6 rows and 7 columns. Each colored disc is "dropped" in the grid by a player, and falls straight down to the lowest available position within the column in which it was dropped. In other words, a dropped disc either falls to the bottom of the column, or onto another disc that had already been dropped in that column.

Each player has 21 discs; one player has blue discs and the other player (in this case, the computer) has green discs. One after the other, the players drop one disc at a time in the grid. When a player manages to make a line, column, or diagonal of 4 discs, the game ends.

What you must do
You must code a game of Connect 4 which is played in a 2D array of 6 rows and 7 columns. A player wins as soon as a line, column or diagonal of 4 discs is made by that player.

Each spot of the 2D array, like all 2D arrays, has a row-column coordinate. The program first asks the player which column the disc has to be dropped into, then checks that it is a valid column, then calculates at which line the disc stops. Of course, as long as the selected column is not valid, the program asks the player for the number of another column. Then, for each disc dropped by player 1 or player 2, your program has to calculate at which line the disc stops.

You must document that game; meaning, you must write a technical design document for it.
You must also write unit tests for at least 4 functions (one unit test per function).

The appearance of the game's grid
To simplify things, the game could be printed to the screen with textual characters. And so, player 1 could have blue discs represented by a ‘B' on the screen and player 2 (the computer) could have green discs represented by a ‘G' on the screen.

Below, you have an example of a game in which player 2 won by putting 4 G(reen) discs in diagonal:

6 | | | | | | | |

5 | | | | | | | |

4 | | | |G|B| | |

3 |B|B|B|G|G| | |

2 |G|G|B|B|B|G| |

1 |B|G|G|G|B|B|G|

- - - - - - - 1 2 3 4 5 6 7

Note: the grid above is only an example of what you might print to the screen. There are many ways to represent a Connect 4 grid on a screen.

Your program, step by step
First, the initial grid is shown on the screen.

Second, you use a prompt to ask the player 1 to enter the number of a column, using the following message:
Which column do you put a disc into?
If the player's input is invalid because it is not a number, you tell the player to enter a number.
If the player's input is invalid because it is a number that falls outside of the grid's boudaries, you tell the player to choose the number of a column.
If the player's input is invalid because the chosen column is already full of discs, you tell the player that it is full and ask him/her to choose another column.
If the player's input is valid, you move on the to the next step.

Third, the grid is shown again on the screen after the disc has been placed by the player. Underneath the grid, a message is shown, saying:
Player has placed a blue disc in row x, column y. For example, such a message could say:
Player has placed a blue disc in row 6, column 7.
This would of course correspond to the row at index 0 and the column at index 6 in the 2D array.

Fourth, the grid is evaluated to see if there is a winner. If there is a winner, the game stops and the winner is signaled through an onscreen message saying:

Player 1 wins!
Then, the program goes to the eighth step.

Fifth, player 2 (the computer) chooses a column to put a disc into.

Sixth, the grid is shown again on the screen after the disc has been placed by player
2. Underneath the grid, a message is shown, saying, for example: Player 2 has placed a blue disc in row 6, column 7.

Seventh, the grid is evaluated to see if there is a winner. If there is a winner, the game stops and the winner is signaled through an onscreen message saying:

Player 2 wins!
Then, the program goes to the eighth step.

Eighth, if there is no winner, the program goes back to the second step. If there is a winner or if this is a draw (if no one wins), the program asks the player if he/she wants to play another game. If the player answers with "yes" or "YES", another game is played from the first step. If not, the program ends.

Hints
Write a function that creates a 2-dimensional array and fills it with empty spots. This function can be initially called to create an array of 6 rows and 7 columns.

Write a function that will be used to print the grid onscreen. Write other functions as needed.

Do not neglect the documentation. Do not neglect the unit tests.

If you want to use the scanner for the player's inputs, but find that Android Studio is giving you trouble in that regard, you can use another IDE.

Attachment:- Instructions.rar

Reference no: EM132766792

Questions Cloud

Calculate the additional profit contribution : Kohinoor Textiles currently has credit sales of Rs.360 million per year and an average collection period of 60 days. Assume that the price of Kohinoor's product
Victim of ransomware : What steps will you take to ensure that you do not become a victim of ransomware?
Specific industries like education-medicine-military : Why institutions are reluctant to move their IT to the cloud. Consider specific industries like education, medicine, military, etc.
Calculate the payback period for the proposed investment : Sydney Printer Ltd is attempting to evaluate the feasibility of investing $200,000 in a new printing machine with a five-year life. The company has estimated th
Write a function that creates a 2-dimensional array : Write a function that creates a 2-dimensional array and fills it with empty spots. This function can be initially called to create an array of 6 rows and 7
Reasons for two new auditing roles in oracle : Discussing the reasons for the two new auditing roles in Oracle 12c. Why did Oracle consider them necessary?
What is the after-tax cash flow for projects : LODH Company, must install safety devices throughout its plant or it will lose its insurance coverage. Two alternatives are acceptable to the insurer.
Security begins in information governance : Where will you agree or disagree that Privacy stops and Security begins in Information Governance?
Write an ethical paper on gun control regulation : Write an ethical paper on Gun control regulation. A paper in moral-ethical philosophy consists of at least six part: the presentation of the arguments.

Reviews

len2766792

1/18/2021 12:52:10 AM

I hope you will go through the rubric and the instructions correctly and dont forget to add UNIT TESTING AND DOCUMENTATION . Please follow the instructions and make my assignment with all the instructions and without missing because i''m scared that i may fail . hope you understand and give me the best results . hope to hear from you soon ., I ATTACHED ASSIGNMENT ZIP AND EXAMPLE FOR TECHNICAL DESIGN DOCUMENT DOWN BELOW.

len2766792

1/18/2021 12:51:37 AM

hello team , here i would like to share some instructions to be followed to complete the assignment . My professor is a completely messed up guy and he needs the work to be done perfectly to get good scores without a single mistake . Like i said , for a small minor mistake he would take out hell lot of marks and thats the reason i''m in my corner of my grades and struggling to pass . The only good thing is instructions to be followed exactly as he mentioned . he asked to code in any language(c++ or java or python ) which can handle the code smoothly and make good efficiency of the code or optimises the code . He also provided guidlines like if we exceed standards then we get a good score and which i provided below marked to get good score and please ONCE GO THROUGH RUBRIC PROVIDED IN EXCEL SHEET TO KNOW THE GRADES GIVEN FOR THE TASKS

Write a Review

Other Subject Questions & Answers

  Cross-cultural opportunities and conflicts in canada

Short Paper on Cross-cultural Opportunities and Conflicts in Canada.

  Sociology theory questions

Sociology are very fundamental in nature. Role strain and role constraint speak about the duties and responsibilities of the roles of people in society or in a group. A short theory about Darwin and Moths is also answered.

  A book review on unfaithful angels

This review will help the reader understand the social work profession through different concepts giving the glimpse of why the social work profession might have drifted away from its original purpose of serving the poor.

  Disorder paper: schizophrenia

Schizophrenia does not really have just one single cause. It is a possibility that this disorder could be inherited but not all doctors are sure.

  Individual assignment: two models handout and rubric

Individual Assignment : Two Models Handout and Rubric,    This paper will allow you to understand and evaluate two vastly different organizational models and to effectively communicate their differences.

  Developing strategic intent for toyota

The following report includes the description about the organization, its strategies, industry analysis in which it operates and its position in the industry.

  Gasoline powered passenger vehicles

In this study, we examine how gasoline price volatility and income of the consumers impacts consumer's demand for gasoline.

  An aspect of poverty in canada

Economics thesis undergrad 4th year paper to write. it should be about 22 pages in length, literature review, economic analysis and then data or cost benefit analysis.

  Ngn customer satisfaction qos indicator for 3g services

The paper aims to highlight the global trends in countries and regions where 3G has already been introduced and propose an implementation plan to the telecom operators of developing countries.

  Prepare a power point presentation

Prepare the power point presentation for the case: Santa Fe Independent School District

  Information literacy is important in this environment

Information literacy is critically important in this contemporary environment

  Associative property of multiplication

Write a definition for associative property of multiplication.

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