Beispiel #1
0
        public void CreateShips()
        {
            Submarine  sub = new Submarine();
            Battleship bb  = new Battleship();
            Carrier    cv  = new Carrier();
            Cruiser    cl  = new Cruiser();
            Destroyer  dd  = new Destroyer();

            shipList = new List <Ship>()
            {
                sub, bb, cv, cl, dd
            };
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            Battleship battleship = new Battleship();

            Console.WriteLine("Push any button to fill the field");
            Console.ReadKey();
            char input;

            do
            {
                battleship.DrawBattlefield();

                Console.WriteLine("\nPush any button to refill the field. Exit: Esc, 'E'");
                input = Console.ReadKey().KeyChar;
            } while (input != 27 && input != 101 && input != 69);
        }
Beispiel #3
0
        /// <summary>
        /// Creates new instances of the ships and adds them to a list that tracks if they are alive or dead
        /// </summary>
        public void CreateShips()
        {
            _gridShips = new List <Ship>();

            //Loop through each type of ship
            foreach (SHIPS ship in Enum.GetValues(typeof(SHIPS)))
            {
                switch (ship)
                {
                case SHIPS.Carrier:
                    carrier = new Carrier(ship.ToString(), (int)SHIP_SIZES.CarrierSize, new SolidColorBrush(Colors.DarkGreen));
                    _gridShips.Add(carrier);
                    break;

                case SHIPS.Battleship:
                    battleship = new Battleship(ship.ToString(), (int)SHIP_SIZES.BattleshipSize, new SolidColorBrush(Colors.SeaGreen));
                    _gridShips.Add(battleship);
                    break;

                case SHIPS.Cruiser:
                    cruiser = new Cruiser(ship.ToString(), (int)SHIP_SIZES.CruiserSize, new SolidColorBrush(Colors.Cyan));
                    _gridShips.Add(cruiser);
                    break;

                case SHIPS.Submarine:
                    submarine = new Submarine(ship.ToString(), (int)SHIP_SIZES.SubmarineSize, new SolidColorBrush(Colors.Yellow));
                    _gridShips.Add(submarine);
                    break;

                case SHIPS.Destroyer:
                    destroyer = new Destroyer(ship.ToString(), (int)SHIP_SIZES.DestroyerSize, new SolidColorBrush(Colors.Violet));
                    _gridShips.Add(destroyer);
                    break;
                }
            }
        }