using namespace std
is considered a bad practice considered a bad practice. Don't do it.
The magic numbers 20 and 30 for the game dimensions would be better as global constants. That way you can easily extend the game to other dimensions.
Instead of:
#include <time.h> #include <stdlib.h>
You should use:
#include <ctime>
#include <cstdlib>
In the boolean functions, instead of returning 0 and 1 values,
it would be more natural to return false
and true
.
In the case
blocks of the switch
statement,
you don't really need the braces,
you could write simpler this way:
switch(direction)
{
case 'd':
y++;
break;
case 'a':
y--;
break;
The condition in the End
function looks odd:
bool End(int &x, int &y) { if (field[x][y] == ' ' ||'H') return 1; return 0; }
The condition will always evaluate to true. You can correct and simplify:
bool End(int &x, int &y)
{
return field[x][y] == ' ' || field[x][y] == 'H';
}
using namespace std
is considered a bad practice. Don't do it.
The magic numbers 20 and 30 for the game dimensions would be better as global constants. That way you can easily extend the game to other dimensions.
Instead of:
#include <time.h> #include <stdlib.h>
You should use:
#include <ctime>
#include <cstdlib>
In the boolean functions, instead of returning 0 and 1 values,
it would be more natural to return false
and true
.
In the case
blocks of the switch
statement,
you don't really need the braces,
you could write simpler this way:
switch(direction)
{
case 'd':
y++;
break;
case 'a':
y--;
break;
The condition in the End
function looks odd:
bool End(int &x, int &y) { if (field[x][y] == ' ' ||'H') return 1; return 0; }
The condition will always evaluate to true. You can correct and simplify:
bool End(int &x, int &y)
{
return field[x][y] == ' ' || field[x][y] == 'H';
}
using namespace std
is considered a bad practice. Don't do it.
The magic numbers 20 and 30 for the game dimensions would be better as global constants. That way you can easily extend the game to other dimensions.
Instead of:
#include <time.h> #include <stdlib.h>
You should use:
#include <ctime>
#include <cstdlib>
In the boolean functions, instead of returning 0 and 1 values,
it would be more natural to return false
and true
.
In the case
blocks of the switch
statement,
you don't really need the braces,
you could write simpler this way:
switch(direction)
{
case 'd':
y++;
break;
case 'a':
y--;
break;
The condition in the End
function looks odd:
bool End(int &x, int &y) { if (field[x][y] == ' ' ||'H') return 1; return 0; }
The condition will always evaluate to true. You can correct and simplify:
bool End(int &x, int &y)
{
return field[x][y] == ' ' || field[x][y] == 'H';
}
using namespace std
is considered a bad practice. Don't do it.
The magic numbers 20 and 30 for the game dimensions would be better as global constants. That way you can easily extend the game to other dimensions.
Instead of:
#include <time.h> #include <stdlib.h>
You should use:
#include <ctime>
#include <cstdlib>
In the boolean functions, instead of returning 0 and 1 values,
it would be more natural to return false
and true
.
In the case
blocks of the switch
statement,
you don't really need the braces,
you could write simpler this way:
switch(direction)
{
case 'd':
y++;
break;
case 'a':
y--;
break;
The condition in the End
function looks odd:
bool End(int &x, int &y) { returnif (field[x][y] == ' ' ||'H') return 1; return 0; }
The condition will always evaluate to true. You can correct and simplify:
bool End(int &x, int &y)
{
return field[x][y] == ' ' || field[x][y] == 'H';
}
using namespace std
is considered a bad practice. Don't do it.
The magic numbers 20 and 30 for the game dimensions would be better as global constants. That way you can easily extend the game to other dimensions.
Instead of:
#include <time.h> #include <stdlib.h>
You should use:
#include <ctime>
#include <cstdlib>
In the boolean functions, instead of returning 0 and 1 values,
it would be more natural to return false
and true
.
In the case
blocks of the switch
statement,
you don't really need the braces,
you could write simpler this way:
switch(direction)
{
case 'd':
y++;
break;
case 'a':
y--;
break;
The condition in the End
function looks odd:
bool End(int &x, int &y) { return field[x][y] == ' ' ||'H') return 1; return 0; }
The condition will always evaluate to true. You can correct and simplify:
bool End(int &x, int &y)
{
return field[x][y] == ' ' || field[x][y] == 'H';
}
using namespace std
is considered a bad practice. Don't do it.
The magic numbers 20 and 30 for the game dimensions would be better as global constants. That way you can easily extend the game to other dimensions.
Instead of:
#include <time.h> #include <stdlib.h>
You should use:
#include <ctime>
#include <cstdlib>
In the boolean functions, instead of returning 0 and 1 values,
it would be more natural to return false
and true
.
In the case
blocks of the switch
statement,
you don't really need the braces,
you could write simpler this way:
switch(direction)
{
case 'd':
y++;
break;
case 'a':
y--;
break;
The condition in the End
function looks odd:
bool End(int &x, int &y) { if (field[x][y] == ' ' ||'H') return 1; return 0; }
The condition will always evaluate to true. You can correct and simplify:
bool End(int &x, int &y)
{
return field[x][y] == ' ' || field[x][y] == 'H';
}
using namespace std
is considered a bad practice. Don't do it.
The magic numbers 20 and 30 for the game dimensions would be better as global constants. That way you can easily extend the game to other dimensions.
Instead of:
#include <time.h> #include <stdlib.h>
You should use:
#include <ctime>
#include <cstdlib>
In the boolean functions, instead of returning 0 and 1 values,
it would be more natural to return false
and true
.
In the case
blocks of the switch
statement,
you don't really need the braces,
you could write simpler this way:
switch(direction)
{
case 'd':
y++;
break;
case 'a':
y--;
break;
The condition in the End
function looks odd:
bool End(int &x, int &y) { return field[x][y] == ' ' ||'H') return 1; return 0; }
The condition will always evaluate to true. You can correct and simplify:
bool End(int &x, int &y)
{
return field[x][y] == ' ' || field[x][y] == 'H';
}