Open krisjans opened 5 years ago
for (k = 0; k < 41; k++)
{
if (laukums[k][r] == '@' | laukums[k][r] == '$')
cout << " "; //@ un $ vietaa izvada atstarpi
else if (k == f1.getKolonna() & r == f1.getRinda())
cout << "o";
else
cout << laukums[k][r];
There should be spaces around operators (+, -, =, ==, >, <, etc) - this makes expressions easier to read;
And after fixing spaces in code sample in previous commit - i spotted a bug: "|" is bit-wise OR. "||" is logic OR.
if (laukums[k][r] == '@' | laukums[k][r] == '$')
Cleaner way of this expression is
if ((laukums[k][r] == '@') || (laukums[k][r] == '$'))
Extra parentheses helps to clearly separate logic operations (instead of relaying on operator precedence (https://en.cppreference.com/w/cpp/language/operator_precedence) and makes code easier to read.
Same abouit & and &&.
https://github.com/EdgarsMelnalksnis/TXTfileGame/blob/ac62fa5bf0acc4795105936efc5e8b9f2efb249b/track.h#L60-L67
use spaces to make expression more readable