Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // SBG.cpp : This file contains the 'main' function. Program execution begins and ends there.
- //
- #include "pch.h"
- #include <iostream>
- #include <string>
- #include <vector>
- #include <math.h>
- using namespace std;
- /*
- class grid{
- private:
- char grid[9][9];
- public:
- void set_grid(char c,int x,int y) {
- grid[x][y]=c;
- }
- char get_grid(int x,int y) {
- return grid[x][y];
- }
- };
- */
- /*
- class grid :public player {
- private:
- char grid[9][9];
- public:
- void set_grid(char c, int x, int y) {
- grid[x][y] = c;
- }
- char get_grid(int x, int y) {
- return grid[x][y];
- }
- };
- class ship {
- private:
- struct coordinates {
- int x;
- int y;
- bool b;
- };
- bool state;
- vector<coordinates> KO;
- public:
- void create_ship() {
- coordinates newcord;
- KO.push_back(newcord);
- }
- void set_coordinates(int x, int y) {
- KO[KO.size()-1].x = x;
- KO[KO.size() - 1].y = y;
- KO[KO.size() - 1].b = true;
- }
- };*/
- /*
- class FreeValues {
- private:
- public:
- void get_free_values_x() {
- FVx.erase(FVx.begin(), FVx.end());
- if (x0 > -1) FVx.push_back(0);
- if (x1 > -1) FVx.push_back(1);
- if (x2 > -1) FVx.push_back(2);
- if (x3 > -1) FVx.push_back(3);
- if (x4 > -1) FVx.push_back(4);
- if (x5 > -1) FVx.push_back(5);
- if (x6 > -1) FVx.push_back(6);
- if (x7 > -1) FVx.push_back(7);
- if (x8 > -1) FVx.push_back(8);
- if (x9 > -1) FVx.push_back(9);
- }
- void get_free_values_y() {
- FVy.erase(FVx.begin(), FVx.end());
- if (y0 > -1) FVy.push_back(0);
- if (y1 > -1) FVy.push_back(1);
- if (y2 > -1) FVy.push_back(2);
- if (y3 > -1) FVy.push_back(3);
- if (y4 > -1) FVy.push_back(4);
- if (y5 > -1) FVy.push_back(5);
- if (y6 > -1) FVy.push_back(6);
- if (y7 > -1) FVy.push_back(7);
- if (y8 > -1) FVy.push_back(8);
- if (y9 > -1) FVy.push_back(9);
- }
- };*/
- class ShipWindow { //:FreeValues
- private:
- int x;
- int y;
- public:
- void set_x(int x) {
- x = x;
- /*
- if (x == 0) minusy0();
- if (x == 1) minusy1();
- if (x == 2) minusy2();
- if (x == 3) minusy3();
- if (x == 4) minusy4();
- if (x == 5) minusy5();
- if (x == 6) minusy6();
- if (x == 7) minusy7();
- if (x == 8) minusy8();
- if (x == 9) minusy9();
- */
- }
- void set_y(int x) {
- y = x;
- /*
- if (y == 0) minusx0();
- if (y == 1) minusx1();
- if (y == 2) minusx2();
- if (y == 3) minusx3();
- if (y == 4) minusx4();
- if (y == 5) minusx5();
- if (y == 6) minusx6();
- if (y == 7) minusx7();
- if (y == 8) minusx8();
- if (y == 9) minusx9();
- */
- }
- int get_x() {
- return x;
- }
- int get_y() {
- return y;
- }
- };
- class Ship {
- private:
- public:
- vector<ShipWindow> ShipVec;
- void new_win() {
- ShipWindow shipwin;
- ShipVec.push_back(shipwin);
- }
- };
- class window {
- private:
- char window;
- public:
- void set_window(char w) {
- //is ok?
- window = w;
- }
- char get_window() {
- return window;
- }
- };
- class grid {
- private:
- window array[9][9];
- public:
- void flush_grid() {
- for (int x = 0; x < 10; x++) {
- for (int y = 0; y < 10; y++) {
- array[x][y].set_window('~');
- }
- }
- }
- void generate_grid() {
- //5 4 4 3 3 3 2 2 2
- if ((rand() % 1) == 0) {
- rand() % 9;
- }
- }
- bool generate_ship(int size) {
- bool state = true;
- while (true) {
- if ((rand() % 1) == 0) {
- int r = (rand() % 1);
- int xr = (rand() % 9);
- int yr = (rand() % 9);
- while (true) {
- if (r == 0) {
- for (int i = 0; i < size; i++) {
- if ((yr + i) < 10) {
- if ((array[xr][yr + i].get_window()) != ('~')) state = false;
- }
- else {}
- }
- }
- else {
- for (int i = 0; i < size; i++) {
- if ((yr + i) > -1) {
- if ((array[xr][yr - i].get_window()) != ('~')) state = false;
- }
- else {};
- }
- }
- else {
- if (r == 0) {
- if (xr + i < 10) {
- for (int i = 0; i < size; i++) {
- if ([xr + i][yr].get_window()) != ('~')) state = false;
- else return false;
- }
- }
- else {
- if (xr - i > -1) {
- for (int i = 0; i < size; i++) {
- if ((array[xr - i][yr].get_window()) != ('~')) state = false;
- }
- else {};
- }
- }
- }
- }
- }
- }
- }
- class Player {
- private:
- string name;
- //int ships;
- bool gamestatus;
- public:
- vector<Ship> S;
- void set_name(string x) {
- name = x;
- }
- string get_name() {
- return name;
- }
- void set_gamestatus(bool x) {
- gamestatus = x;
- }
- void newship() {
- Ship newship;
- S.push_back(newship);
- }
- Player() {
- gamestatus = true;
- FreeValues FV;
- }
- };
- //bool assign_window(int x, int y)
- };
- int main()
- {
- Player P;
- Player AI;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement