#include <iostream>
#include <ctime>
#include <list>
#include <string>
#include <ctime>
#include <Windows.h>
#include <stdlib.h>

using namespace std;

const int rowup = 4;
const int location = 4; // 4 locations

char rematch = '\0';
class player1& p1;  // declaring class for player
int computer; // declaring class for computer
int maxships = 4; // this is how many ships are in the game
class ShowGrid;
int getscore;
int ArrayTest;
int ArrayStartsEmpty;

int a[rowup][location]; // the use of a two dimensional array is used here to declare my intergers -  a is my matrix

void ClearArray() // void function, this looks for an array 
{
    for (int x = 0; x < rowup; x++) // 0 will represent if the ship is not at that location
    {
        for (int v = 0; v < location; v++) // if v is greater than location, this then clears the array
        {
            a[x][v] = 0;
        }
    }
}

void ShowArray() // function to show an array
{
    for (int x = 0; x < rowup; x++)
    {
        for (int v = 0; v < location; v++)
        {
            cout << a[x][v] << " "; // this time the value is being printed the value, above is setting the value
        }
        cout << endl;
    }
}

void displayScore()
{
    cout << endl;
    cout << "SCORE:";
    if (computer)
        cout << " Player 1: " << player1.displayScore() << " Computer: " << computer.displayScore() << endl;
}

void Location() // this puts the ships in a random location
{
    int l = 0; // l virbile represents the current number of ships
    while (l < maxships) // while l is smaller than maxships 
    {
        int x = rand() % rowup; // this rand makes the ship in random rows 
        int y = rand() % location; // this rand makes the ships place in random locations
        if (a[x][y] != 1) //  if a ship isn't located at this position a 
        {
            a[x][y] = 1;
            cout << "Ship has been set at random location";
        }
    }
}

class ShipType { // ship class
    int Type;
    int Size;
};

class Type {    // different type of ships
    char Destroyer;
    char Corvettes;
    char AssultShip;
    char Frigates;
};

class Size {       // different sizes of hits based of ships
    int Destoryer = 2;
    int Corvettes = 1;
    int AssultShip = 3;
    int Fridgates = 1;
};

int TEST(int ShowArray)
    {
    ShowArray;
    EXPECT_EQ(0, array.0);

}

bool Hit(int x, int y) // this is validation to check if the ship has been hit or not, x and y are the two made parameters
{
    if (a[x][y] == 1)
    {
        a[x][y] = 2;
        return true; // if ship has been hit output message will be displayed 
    }
    return false; // this is linked to the else function that displays the output message if the user misses
}

int main()
{
    srand(time(NULL)); // this allows it to be fully randomise
    int pos3, pos2;
    while (1)
    {
        cout << "Input your location to fire upon "; cin >> pos3 >> pos2;
        if (Hit(pos3, pos2))
            cout << "Hit" << endl; // if ship has been hit output message will be displayed
        else
            cout << "Miss" << endl; // if user misses the ship output message of miss will be presented
    }
    return 0;
};

class display { // left off on this step last time - displaying different screens
private:
    int Hit, ship_hit;
    int Score;
    char player1, computer;

    void displayscreen(player1, computer) {
        int i, j, k;
        bool score = false;
        char ship_hit;

        score = true;
        for (j = 0; j < 4; j++) { // if hits greater than 4 play 1 wins, there are only 4 ships

            if (score) {
                ship_hit = 4; // if player gets 4 on ship hits this means all computer's ships have been destoryed
                if (ship_hit == 1) {
                    cout << "-----------------------" << endl;
                    cout << "\t Player 1 WON" << endl;
                    cout << "-----------------------" << endl;
                    player1.won();
                }
                else { // else computer display comes
                    computer.won();
                    if (computer) {
                        cout << "-----------------------" << endl;
                        cout << "\t Computer WON" << endl;
                        cout << "-----------------------" << endl;
                    }

                }

            }
        }

    }
};

int init() {

}

int main() // main menu
{
    int ch;

    while (1) {
        cout << "      MENU" << endl;
        cout << "\t 1. Rules" << endl;
        cout << "\t 2. Play" << endl;
        cout << "\t 3. Quit" << endl;
        cout << endl;
        cin >> ch;
        switch (ch) {
        case 1: {

        }
              break;
        case 2: {

        }
              break;
        case 3:
            return 0;
        }

        // this code is run when the loop is exited.

        cout << "Game Over!" << endl;
        cout << "Your Grid: " << endl;
        player1 ShowGrid(); // this is to display the grid at the end of the match


    } while ((rematch == 'y')) || ((rematch == 'Y')) {
        init();
        return 0;
    }
}
