Battleship Game Help in C++

Posted 07 December 2009 - 12:49 PM

I had already posted a previous question about this program a week ago. No one replied...that sucks...So here is what i came up with for anyone interested in the code so far.
Note: This is not the final code for the project..i am having a few prblems if anyone can help me with it. Help would be greatly appreciated.

Basically how do i
1.) show the status of the ships in the PlaySingleMode() function?..when if you run the program..the menu deal at the top...the one with ENEMY: and STATUS:? I was going to use AT LARGE! and SUNK! for the status.
but how do i do it?
2.) When a ship is hit it is supposed to put an "*" on the screen/Grid..it only puts the " " letter of the boat hit, which isnt supposed to be displayed until it is sunk, only the asterick is.?

Replies To: Battleship Game Help in C++

Re: Battleship Game Help in C++

Posted 07 December 2009 - 01:53 PM

One reason why you don't get replies is because the code is long. People don't want to take the time to read all of it. If you could point out specific problem sections and what is supposed to happen that would help.

Re: Battleship Game Help in C++

Posted 07 December 2009 - 08:50 PM

eker676, on 7 Dec, 2009 - 12:53 PM, said:

One reason why you don't get replies is because the code is long. People don't want to take the time to read all of it. If you could point out specific problem sections and what is supposed to happen that would help.

Well i sort of did, but i just kind of figured that if someone wanted to helpme then they would need the code to see where i wen wrong..sorry for such the long code everyone!

here is where im having trouble..In the PlaySingleMode Function()

Basically how do i
1.) show the status of the ships in the PlaySingleMode() function?..when if you run the program..the menu deal at the top...the one with ENEMY: and STATUS:? I was going to use AT LARGE! and SUNK! for the status.
but how do i do it?
2.) When a ship is hit it is supposed to put an "*" on the screen/Grid..it only puts the " " letter of the boat hit, which isnt supposed to be displayed until it is sunk, only the asterick is.?

here is the code..but the whole function i need help in as well..sorry if it long but i figure u need it to help..Thanks for any replies

Re: Battleship Game Help in C++

Posted 08 December 2009 - 12:39 AM

dfournie, on 7 Dec, 2009 - 09:50 PM, said:

Basically how do i
1.) show the status of the ships in the PlaySingleMode() function?..when if you run the program..the menu deal at the top...the one with ENEMY: and STATUS:? I was going to use AT LARGE! and SUNK! for the status.
but how do i do it?

2.) When a ship is hit it is supposed to put an "*" on the screen/Grid..it only puts the " " letter of the boat hit, which isnt supposed to be displayed until it is sunk, only the asterick is.?

You're right. I need the code in order to see where the problem might be. It's not too long.

Here's what I would try, to solve your first issue:

//Prints out the title again and the current status of the targets/boats.
//This is represented either by "At Large" or "Sunk".
cout << " B A T T L E S H I P\n\n";
cout << "ENEMY : Aircraft Carrier Battleship Cruiser";
cout << " Submarine Destroyer" << endl;
cout << setw(7) << " ----------------------------------------------";
cout << "-----------------------" << endl;
cout << "STATUS :\n\n";
//I'd do something like this. Use "\t" for tabs, for easier formatting.
//then you can use if statements here. Like if your battleship is full (maybe
//do a search of the entire board to see how many B's it contains? Or whenever
//a new B is printed, increment BattleshipCounter. When it gets to 10, the number
//of letters in battleship, then set bool battleshipSunk to true. Use functions
//for this. Then when you get to THIS part of the code, do this for each ship:
if(battleshipSunk){
cout <<"\t\tSUNK!";
}
else {
cout <<"\t\tAT LARGE!";
}
//I didn't test it. I'm pretty sure it will work though. Good luck! :)