Discuss how to implement given methods

Assignment Help C/C++ Programming
Reference no: EM132043626

Question: Problem: In this program you will be mimicking a game of Battleship. Your game board is a line of 10 slots. You have to implement 3 methods. The following methods must be implemented:

void setBoard(int *)

This method sets up the human's game board. The method prompts the user for 2 slots to place the "ship". The program should ensure that the slots are consecutive. In other words, your ship cannot be placed at slot 2 and at slot 6. Since the board has only 10 slots, valid slots are in the range of 0 to 9.

void setComputerBoard(int *)

Exactly the same as the setBoard method except that the position of the computer's ship is set randomly. The computer's ship must also be in consecutive slots.

intplayGame(int *, int *)

This method should do the following steps:

1. Have the computer pick at random a slot to "fire" at. If the slot the computer picked on the human's board is a ship, a "HIT" message is displayed. If the slot on the human's board is empty, a "MISS" message is displayed. Print out the computer's board and the human's board as described at the bottom of the page.

2. After the computer goes, have the human pick a slot to "fire" at. If the slot the human picked on the computer's board is a ship, a "HIT" message is displayed. If the slot on the computer's board is empty, a "MISS" message is displayed. Print out the computer's board and the human's board as described at the bottom of the page.

3. Repeat steps 1 and 2 until there is a winner. The computer wins if both of the human's ship slots are hit. The human wins if both of the computer's ship slots are hit.

The playGame method returns a 0 if the computer won. The playGame method returns a 1 if the human won.

The computer board is printed off with the following characters: (The human board is printed off similarly)

S - printed off in the slots where the computer's ship is located.

M - printed off in the slots where the human guessed incorrectly.

H - printed off in the slots where the ship is located and where the human hit.

* - printed off in all other slots

You can assume the input will always be a positive integer.

Important: You should use pointer notation when referencing values inside an array as opposed to array notation. For example, use *ptrToArray instead of array[0] and *(ptrToArray+1) instead of array[1], etc. You will lose 10 points for not following this notation.

Information related to above question is enclosed below:

Attachment:- HW4-.rar

Reference no: EM132043626

Questions Cloud

Create the pro forma cash flow statement for investment : When getting into a project of this type you generally consider a 5-year holding period and look for a 12% rate of return.
Find the effective rent for option : Find the effective rent for each option given the following lease conditions over the next 5 years using a 12% discount rate:
Book value of equity to calculate enterprise value : For a publicly traded company, should we use the book value of equity to calculate Enterprise Value?
Prepare presentation about conflict management : The subject is customer service - You need to prepare presentation about conflict management and probably do the critical thinking
Discuss how to implement given methods : Problem: In this program you will be mimicking a game of Battleship. Your game board is a line of 10 slots. You have to implement 3 methods.
What is the current stock price : A stock just paid a dividend of D0 = $1.50. The required rate of return is rs = 14.1%, and the constant growth rate is g = 4.0%. What is the current stock pric
Rate of return on similar investments : What is one share of this stock worth to you if you require a 10% rate of return on similar investments?
How much are you willing to pay to buy one share : How much are you willing to pay to buy one share of this stock today if your desired rate of return is 10.0 percent?
What will the dividend be five years from now : Atlas Mines has adopted a policy of increasing the annual dividend on its common stock at a constant rate of 3.00 percent annually.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

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