Hi :) I only recently started programmins, and so need a bunch of help with several parts of my program.
How can I make it so the machine randomly selects a phrase (such as "ship hit" or "Missed!") to print after a section of the array is targetted by the player or machine?
I have a random (static Random RandomNumber = new Random(); ) at the top and wanted to use for this, but can't work out how to make the list of phrases for it to choose from. A list of enums is what I'vr been trying to make, but it's not working for me.
Another thing, I currently have it so the Array for the player ships is displayed at the end of every turn. How would I make it print both the player, and enemy arrays next to one another? It doesn't matter about it letting the player see the enemy ships, I just want to check everything's woprking.
And lastly, again about the array, how would I alter the way it's displayed? Currently it's just a square of 0's with 1's as boats and 2's as bombed sections. How would I go about making the sea be displayed as ~, the boats as ^, etc.
I'm sorry for asking what must seem like such obvious questions, but I don't want to flounder around at the code doing nothing to keep my motivation up, and google isn't being a help. Any good help sites would also be great.
1 reply to this topic
#1
Posted 19 December 2010 - 08:25 AM
|
|
|
#2
Posted 19 December 2010 - 03:19 PM
for what it's worth, you more than likely don't want it to randomly say hit or miss
you likely want it to say hit or miss depending on if you hit a ship or not.
An emum wouldn't be used for this phrase. I would just output a constant value when such a condition is met.
nested for loops should be adequate to print the contents of your sea, if you've used multi-dimensional arrays.
eg
you likely want it to say hit or miss depending on if you hit a ship or not.
An emum wouldn't be used for this phrase. I would just output a constant value when such a condition is met.
nested for loops should be adequate to print the contents of your sea, if you've used multi-dimensional arrays.
eg
for (int i = 0; i < MaxWidth; i++) {
for(int k = 0; k < MaxHeight; k++)
Console.Write(sea[i][k]);
Console.WriteLine();
}
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account

Back to top









