Computer Science Canada battleship |
Author: | Jenkinz [ Tue May 16, 2006 8:46 am ] | ||
Post subject: | battleship | ||
im trying to make my battleship program so that i would be able to put in if five ships were hit by the user then put "you win" but i tried with counters and it didnt seem to work any help would be appreciated
|
Author: | Jenkinz [ Tue May 16, 2006 8:48 am ] |
Post subject: | |
i also believe i need a loop as well because the program stops after you type in the first longitude and lagitude? |
Author: | Clayton [ Tue May 16, 2006 3:27 pm ] |
Post subject: | |
you are correct, you would need to put in a loop because you are doing the same thing over and over again (unless your five ships are in exactly the same spot and only have one hit each lol) to check and see if all of your ships were hit, you could have a record with an array of booleans to keep track of what ships are hit as well as how many, and if youve won or not ![]() |
Author: | Jenkinz [ Wed May 17, 2006 8:57 am ] | ||
Post subject: | |||
i went through the walkthrough and it helped but im trying a new concept of the battleship game that allows you to input the positions of your ship into a 2d array, and another player player to play unti they either hit the ship in which case it tells you you what type of ship you have hit Ive got everything down except that im not sure how to make it so that whenever i hit and sink a ship it will show something or another ship other than Submarine, so whenever i keep hitting a ship it keeps saying Submarine is hti and sunk, take a look i need some help fixing this, thanks
|
Author: | TheOneTrueGod [ Wed May 17, 2006 2:06 pm ] | ||||
Post subject: | |||||
that would be your problem... Think about it, what is the ONLY value that "u" will ever be? now, what did you declare ships (1) as? !
Submarine |
Author: | Jenkinz [ Wed May 17, 2006 5:54 pm ] |
Post subject: | |
i changed U to 1..5, then when i ran the program it didnt state the ship hit at all ![]() |
Author: | MysticVegeta [ Wed May 17, 2006 6:02 pm ] |
Post subject: | |
Why are you making it so complicated? Why not use records?? Also, you are taking width and height as an input too, you shouldnt do that because in battleship I think you are supposed to guess only 1 point on the cartesian plane and thats it, you "sunk" a ship if all parts of the ship are destroyed.. |