PasteSite is open to the public, but with limited features. Register to be able to modify access rights, track your pastes and more...
If you prefer reading light text on a dark background to dark text on a light background, then you might want to try the dark theme.
"Untitled" by Anonymous [Plain Text]Actions:
Replies: |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
using System;
class Battleships
{
const int Sea_Width = 10;
const int Sea_Height = 10;
const int Empty_Sea = 0 ;
const int Attacked = 1 ;
const int Battleship = 2 ;
const int Cruiser = 4 ;
const int Sub = 8 ;
const int Rowing_Boat = 16 ;
static int i;
static int j;
static int menu;
static string menuString;
static int [,] Sea = new int [Sea_Width,Sea_Height];
static void ClearSea()
{
for (i = 0 ; i < 9 ; i = i + 1)
{
Sea [i,j] = 0;
}
for (j = 0 ; j < 9 ; j = j + 1)
{
Sea [i,j] = 0;
}
}
static void DisplaySea()
{
for (i = 0 ; i < 10 ; i = i + 1)
{
Console.Write (Sea [i,j]);
for (j = 0 ; j < 9 ; j = j + 1)
{
Console.Write (Sea [i,j]);
}
Console.WriteLine("");
}
}
static void PlaceShips()
{
Sea[0,2] = Battleship;
Sea[1,6] = Battleship;
Sea[0,4] = Cruiser;
Sea[1,0] = Cruiser;
Sea[9,9] = Cruiser;
Sea[5,5] = Sub;
Sea[7,8] = Rowing_Boat;
}
static void Main()
{
ClearSea();
PlaceShips();
Console.Write("Please make your choice : ");
menuString = Console.ReadLine();
menu = int.Parse(menuString);
if(menu == 1)
{
DisplaySea();
}
}
}
|