Ask Question, Ask an Expert

+1-415-315-9853

info@mywordsolution.com

Ask C/C++ Expert


Home >> C/C++

problem 1) Implement this function in C:

void populateGameBoard(char gameBoard[][COL_SIZE], int rowSize, int colSize, int numPieces);

This function takes in entire game board passed from main, the row size, the column size of the playable game board, and number of pieces to place (num_pieces). Inside the function develop the way to populate 2D array randomly by calling getPieceType (basically function which randomly generates (returns) character of either 'T' or 'A') to obtain either ‘A’ or ‘T’ to place on the playable game board portion up to the size of numPieces. numPieces is decided by the row size of the 2D array -- meaning that if rowSize = 10, then the board would start with 10 game pieces.

Note: This function also should handle the case that max element size would be met and number of units plus incoming number pieces would create an infinite loop. Develop the way to prevent the infinite loop.

A solution is below

For ex: a 3 * 3 game board has at max 9 elements but also requires a placement of 3 additional units, but already 7 units present on game board. If this is the case decrement the number of additional units to fit the max number of units in the playable game board portion.

THIS IS WHAT THE GAMEBOARD LOOKS LIKE:

Player's life left is [100]

Number of devastor missiles is [0]

Player's score is [0]

    a     b      c    d     e     f     g     h      i      j
a [   ] [   ] [   ] [   ] [   ] [   ] [   ] [ A  ] [   ] [   ]
b [   ][ T ] [   ] [   ] [   ] [   ] [   ] [   ] [   ] [   ]
c [   ] [   ] [   ] [   ] [ A  ] [   ] [   ] [   ] [   ] [   ]

C/C++, Programming

  • Category:- C/C++
  • Reference No.:- M94704

Have any Question? 


Related Questions in C/C++

Projectdecision statementsdirections read carefully and

Project: Decision Statements Directions (Read CAREFULLY and follow COMPLETELY): - Create the following programs in C++ that perform the purpose described and show the sample output (with user input where applicable). - I ...

Cosci 21a programming assignmentpurpose experience with

COSCI 21a, Programming Assignment Purpose: Experience with some basic data structures, including circular queues, linked lists, hash tables, and specifically with pointers and the associated dynamic memory allocation. Pr ...

Write a c application that does the followingitem 1 prompts

Write a C++ application that does the following: ITEM 1: Prompts the user to choose one of the following series: 1 + 1/2 + 1/3 + ... + 1/n ((((x * 2) * 2) * ...) * 2) series of n multiplications x + (x * 1) + (x * 2) + ( ...

C-programmingcreate a c program that sorts a sequence of

C-Programming Create a C program that sorts a sequence of positive numbers using the bubble sort algorithm in an increasing or decreasing order based on the user's choice. The pseudo code for the bubble sort algorithm is ...

Programming cc assignmentsyoull need to download this to

Programming C/C++ assignments You'll need to download this To write the program. The programs will be written using the Microsoft Visual C++ Express Edition IDE (Integrated Development Environment), which can be download ...

Assignmentconsider the following declarationsclass

Assignment Consider the following declarations: class bagType { public: void set(string, double, double, double, double); void print() const; string getStyle() const; double getPrice() const; void get(double, double, dou ...

Assignmentpart acomplete the following questionswrite c

Assignment Part A Complete the following questions: Write C++ code to open a document with the name Hello.txt, place the message "Hello, World!" in the document, and exit the document. Re open the file you closed, and re ...

1 write a c program that allows the user to create a test

1. Write a C++ program that allows the user to create a test bank of questions 2. The program should first ask the user how many questions he or she wishes to create. 3- The user should now be prompted for all informatio ...

Discussionkeyboard versus file input please respond to the

Discussion "Keyboard versus File Input" Please respond to the following: • Suppose you are designing a C++ application that needs to capture user input specifically via a keyboard or from a file. Determine the method tha ...

Assignmentwhen writing c programs include comments in your

Assignment When writing C++ programs include comments in your code, make the program readable by indenting, use meaningful variable and function names, and produce meaningful output. This assignment will be to write a bm ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

WalMart Identification of theory and critical discussion

Drawing on the prescribed text and/or relevant academic literature, produce a paper which discusses the nature of group

Section onea in an atwood machine suppose two objects of

SECTION ONE (a) In an Atwood Machine, suppose two objects of unequal mass are hung vertically over a frictionless

Part 1you work in hr for a company that operates a factory

Part 1: You work in HR for a company that operates a factory manufacturing fiberglass. There are several hundred empl

Details on advanced accounting paperthis paper is intended

DETAILS ON ADVANCED ACCOUNTING PAPER This paper is intended for students to apply the theoretical knowledge around ac

Create a provider database and related reports and queries

Create a provider database and related reports and queries to capture contact information for potential PC component pro