/***********************************************************     Copyright 2003 Rick Miller - Pulp Free Press           This source code accompanies the text C++ For Artists     and is provided for instructional purposes only. No      warranty concerning the quality of the code is expressed     or implied.	 You are free to use this code in your programs so long	 as this copyright notice is included in its entirety.**********************************************************/#include "userinterface.h"#include <stdlib.h>UserInterface::UserInterface():spaces(0){   int rows(0), columns(0);   cout<<"Enter Max Rows: ";   cin>>rows;   cout<<endl<<"Enter Max Columns: ";   cin>>columns;   its_rows = rows;   its_columns = columns;   floor = new bool*[rows];   for(int  i = 0; i<rows; i++){     floor[i] = new bool[columns];   }     for(int i=0; i<rows; i++){    for(int j=0; j<columns; j++){      floor[i][j] = false;       }    }}UserInterface::~UserInterface(){  for(int i=0; i<its_rows; i++){    delete[] floor[i];  }    delete[] floor;}void UserInterface::displayMenu(){  cout<<"       1. Add New Rat"<<endl;  cout<<"       2. Toggle Rat"<<endl;  cout<<"       3. Turn Right"<<endl;  cout<<"       4. Turn Left"<<endl;  cout<<"       5. Set Tail Up"<<endl;  cout<<"       6. Set Tail Down"<<endl;  cout<<"       7. Move"<<endl;  cout<<"       8. Display Floor"<<endl;  cout<<"       9. Exit"<<endl;  cout<<endl;  cout<<endl;}int UserInterface::getMenuChoice(){  char c[1];  cin>>c[0];  while((c[0] < '1') || (c[0] > '9')){    cout<<"Please enter a valid menu choice"<<endl;    cin>>c;  }    return atoi(c);}void UserInterface::markFloor(int row, int column){  floor[row][column] = true;}void UserInterface::clearFloor(int row, int column){floor[row][column] = false;}void UserInterface::displayFloor(){ for(int i = 0; i<its_rows; i++){    for(int j = 0; j<its_columns; j++){        if(floor[i][j]){          cout<<'*';        }else{          cout<<'0';        }     }    cout<<endl;  } }int UserInterface::getRows(){  return its_rows;}int UserInterface::getColumns(){  return its_columns;}int UserInterface::getSpaces(){  cout<<endl<<"Enter spaces to move: ";  cin>>spaces;  return spaces;}
