Get Instant Help From 5000+ Experts For
question

Writing: Get your essay and assignment written from scratch by PhD expert

Rewriting: Paraphrase or rewrite your friend's essay with similar meaning at reduced cost

Editing:Proofread your work by experts and improve grade at Lowest cost

And Improve Your Grades
myassignmenthelp.com
loader
Phone no. Missing!

Enter phone no. to receive critical updates and urgent messages !

Attach file

Error goes here

Files Missing!

Please upload all relevant files for quick & complete assistance.

Guaranteed Higher Grade!
Free Quote
wave
Modifying InitFields Function in a Game

Modifying initFields() Function to Populate Holes Randomly

Discuss how you can modify the initFields() function to randomly populate the holes (O) in the field every time the player starts the game. The number of holes (O) generated should be less than the fields (X). Implement your solution to populate the holes (O). Figure Q1-3 shows an example of the field with randomly generated holes (O). (b) Implement the following functions: (i) void createPlayer() – This function assigns the position of the player (C) by generating 2 random numbers (row and column) within the field. (ii) void createKey() – This function assigns the position of the key (K) by generating 2 random numbers (row and column) within the field. You need to ensure that the key (K) do not replace the position of the player (C). Figure Q1-4 shows an example of the random generated position of the player (C) and the key (K). Figure Q1-4 (iii) void getInput() – This function shows “Enter a direction (u,d,l,r):” in the output, and gets the input from the player and pass the input as an argument to moveChar(char input) function. Figure Q1-5 shows an example of the output. (iv) bool moveChar(char input) – This function returns a boolean which indicates whether the player should continue the game or the game should end when the player drop into a hole or gets the key. This function will check if input is valid. If input is valid, the function will pass in the next position of the player to checkMove(int row, int col). If the input is not valid, an error message will be shown in the output as “Invalid direction input. Please enter again”. Figure Q1-6 shows an example of the output. Figure Q1-6 (v) void checkMove(int row, int col) -- This function returns a boolean which indicates whether the player should continue the game or the game should end when the player drop into a hole or gets the key. The function will check the following conditions. a. Player is out of field’s boundary – Display the message “Out of boundary! Please try again!” and the game will get the player to input again. Figure Q1-7 shows an example of the output. b. Player fall into a hole – Display the message “You fell into the hole. Game Over” and end the game. Figure Q1-8 shows an example of the output. c. Player gets the key – Display the message “Congratulations! You have gotten the Key. Game End” and end the game. Figure Q1-9 shows an example of the output. Question 2 The WeeklyPay class calculates the weekly pay-out of an employee. The class consist three data members namely name, weekNum and dailyPay. Identify suitable coding modules for the WeeklyPay class with the following specifications. (a) Define the three data members: (i) name as a string to store the employee name. (ii) weekNum as an integer to store the weeks of the month (e.g., 1 represent the 1st week of the month, 2 represent the 2nd week of the month). (iii) dailyPay as an integer array with the array size of 5 to store the pay per day from Monday to Friday. (b) Implement a parameterised constructor that receives three arguments that represent the values of name, weekNum, and dailyPay respectively. The constructor will initialise the three data members with the arguments. (c) Write a totalPayPerWeek function to calculate the total pay per week. (d) Write a getPay getter function to return the dailyPay data member. (e) Overload the << operator so that the statements

support
Whatsapp
callback
sales
sales chat
Whatsapp
callback
sales chat
close