Amit Kumar
BAN USERuint8_t u8Rows=8, u8Cols=8;
vector<vector<int>> vecChessBoard(u8Rows, vector<int>(u8Cols,0));
std::stringstream oSS;
std::cout<<"Enter knight position row, col";
std::cin>>i>>j; //i=row, j=col
//There can be 8 knight positions
int8_t i=0,j=0;
if((i+1 < u8Rows) and (j+1 < u8Cols))
oSS << "(" << i+1 << "," << j+2 << ")" << std::endl;
if((i-1 > -1) and (j+1 < u8Cols))
oSS << "(" << i-1 << "," << j+1 << ")" << std::endl;
if((i+2 < u8Rows) and (j+1 < u8Cols))
oSS << "(" << i+2 << "," << j+1 << ")" << std::endl;
if((i+2 < u8Rows) and (j-1 > -1))
oSS << "(" << i+2 << "," << j-1 << ")" << std::endl;
if((i+1 < u8Rows) and (j-2 > -1))
oSS << "(" << i+1 << "," << j-2 << ")" << std::endl;
if((i-1 > -1) and (j-1 > -1))
oSS << "(" << i-1 << "," << j-1 << ")" << std::endl;
if((i-2 > -1) and (j-1 > -1))
oSS << "(" << i-2 << "," << j-1 << ")" << std::endl;
if((i-2 > -1) and (j+1 < u8Cols))
oSS << "(" << i-2 << "," << j+1 << ")" << std::endl;
std::cout << oSS.str();
I think 3 design patterns will be used:
- Amit Kumar July 03, 20211. Observer: Robot subscribes to user's commands, also when meal is ready.
2. Factory Method: Robot provides separate interface to user, and prepares meal with help of separate class at backend.
3. Command: Takes command to edit menu. Add item, remove item etc