-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathClass.h
52 lines (49 loc) · 1.07 KB
/
Class.h
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
#pragma once
#include "Class.cpp"
//Field::Field() {
//
//}
Field::Field(int n_, int m_){
n = n_; m = m_;
field = new char* [n];
for (int i = 0; i < n; i++) {
field[i] = new char[m];
}
}
void Field::FieldZeroFill() {
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++) {
field[i][j] = 'O';
}
}
Field::~Field() {
for (int i = 0; i < n; i++)
delete field[i];
delete field;
}
void Field::FieldCompFill(char** field_) {
// ñäåëàòü çàïîëíåíèå ìàòðèöû êîðàáëÿìè
}
void Field::FieldPlayerFill() {
int maxships = 0;
while (maxships <= 20) {
int row, column;
std::cout << "Row: "; std::cin >> row;
std::cout << "Column: "; std::cin >> column;
char ch;
std::cout << "Enter '+' to place the ship in the cell (" << row << ", " << column << ") or 'e' for exit.\nEnter: ";
std::cin >> ch;
field[row][column] = ch;
if(ch=='e')
return;
maxships++;
}
}
void Field::fieldOut() {
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
std::cout << field[i][j]<<" ";
}
std::cout << std::endl;
}
}