ekulfest
December 10th, 2008, 02:46 PM
how can i make an input by the user which places ships on the grid
namespace battleships20
{
enum seastate
{
EmptySea,
Attacked,
Battleship,
Cruiser,
Submarine,
Destroyer
};
class BattleShipsPlayer
{
const int SEA_WIDTH = 10;
const int SEA_HEIGHT = 10;
static int[,] sea = new int[SEA_WIDTH, SEA_HEIGHT];
static void clearSea()
{
// Clears the sea to empty
}
static void placeShips()
{
// Places ships as follows:
// Battleship: (0,2) and (1,6)
// Cruiser: (0,4), (1,0) and (9,9)
// Submarine: (5,5)
// Rowing boat:(7,8)
}
static void displaySea()
{
}
// Displays the sea on the users screen
static void Main(string[] args)
{
{
string userName;
Console.Write("Please Enter your Name: ");
userName = Console.ReadLine();
Console.WriteLine("");
//On the next line, display the input.
//{0} is where the variable value will go. It
//is followed by a comma and variable name userName
Console.WriteLine("Hello {0}!", userName);
Console.WriteLine("Enter the coordinates of your ship");
//The Console.Readline will pause the program until you
{
for (int x = 0; x < SEA_WIDTH; x++)
{
for (int y = 0; y < SEA_HEIGHT; y++)
{
Console.Write(sea[x, y]);
Console.Write("\t");
}
Console.WriteLine();
{
}
}
{
}
}
}
}
}
}
namespace battleships20
{
enum seastate
{
EmptySea,
Attacked,
Battleship,
Cruiser,
Submarine,
Destroyer
};
class BattleShipsPlayer
{
const int SEA_WIDTH = 10;
const int SEA_HEIGHT = 10;
static int[,] sea = new int[SEA_WIDTH, SEA_HEIGHT];
static void clearSea()
{
// Clears the sea to empty
}
static void placeShips()
{
// Places ships as follows:
// Battleship: (0,2) and (1,6)
// Cruiser: (0,4), (1,0) and (9,9)
// Submarine: (5,5)
// Rowing boat:(7,8)
}
static void displaySea()
{
}
// Displays the sea on the users screen
static void Main(string[] args)
{
{
string userName;
Console.Write("Please Enter your Name: ");
userName = Console.ReadLine();
Console.WriteLine("");
//On the next line, display the input.
//{0} is where the variable value will go. It
//is followed by a comma and variable name userName
Console.WriteLine("Hello {0}!", userName);
Console.WriteLine("Enter the coordinates of your ship");
//The Console.Readline will pause the program until you
{
for (int x = 0; x < SEA_WIDTH; x++)
{
for (int y = 0; y < SEA_HEIGHT; y++)
{
Console.Write(sea[x, y]);
Console.Write("\t");
}
Console.WriteLine();
{
}
}
{
}
}
}
}
}
}