{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

cs32projectsolutions

cs32projectsolutions - Project 1 Solution In this solution...

Info icon This preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
Project 1 Solution In this solution to Project 1 , here is what was affected by the addition of the history feature: The files History.h and History.cpp , containing the declaration and the implementation of the History class. The declarations of Arena::history and Arena::m_history in Arena.h . The implementations of Arena::Arena and Arena::history in Arena.cpp . The implementation of the h command in Game::play in Game.cpp . The implementations of the Player::stand and Player::move in Player.cpp . To help you understand why each header was included, and why some were not (e.g., why Arena.h does not include Robot.h ), here's a synopsis of each file: // globals.h #ifndef GLOBALS_INCLUDED #define GLOBALS_INCLUDED ... class Arena; attemptMove uses Arena& ... #endif // GLOBALS_INCLUDED // Arena.h #ifndef ARENA_INCLUDED #define ARENA_INCLUDED #include "globals.h" Arena uses MAXROBOTS, etc. #include "History.h" Arena declares a History data member #include <string> Arena uses std::string class Robot; Arena uses Robot* class Player; Arena uses Player* class Arena { ... }; #endif // ARENA_INCLUDED // Game.h #ifndef GAME_INCLUDED #define GAME_INCLUDED #include <string> Game uses std::string class Arena; Game uses Arena*
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
class Game { ... }; #endif // GAME_INCLUDED // History.h #ifndef HISTORY_INCLUDED #define HISTORY_INCLUDED #include "globals.h" History uses MAXROWS and MAXCOLS class History { ... }; #endif // HISTORY_INCLUDED // Player.h #ifndef PLAYER_INCLUDED #define PLAYER_INCLUDED #include "globals.h" Player uses Dir #include <string> Player uses std::string class Arena; Player uses Arena* class Player { ... }; #endif // PLAYER_INCLUDED // Robot.h #ifndef ROBOT_INCLUDED #define ROBOT_INCLUDED #include "globals.h" Robot uses Dir class Arena; Robot uses Arena* class Robot { ... }; // Arena.cpp #include "Arena.h" We define Arena::Arena, etc. #include "Player.h" We use Player::Player, etc.
Image of page 2
#include "Robot.h" We use Robot::Robot, etc. #include "History.h" We use History::History, etc. #include "globals.h" We use MAXROWS, etc. #include <iostream> We use std::cout, etc. #include <string> We use std::string #include <cstdlib> We use std::exit, etc. using namespace std; ... // Game.cpp #include "Game.h" We define Game::Game, etc. #include "Arena.h" We use Arena::Arena, etc. #include "Player.h" We use Player::move, etc. #include "History.h" We use History::display #include "globals.h" We use MAXROBOTS, etc. #include <iostream> We use std::cout, etc. #include <string> We use std::string #include <cctype> We use std::tolower #include <cstdlib> We use std::exit, etc. #include <cassert> We use assert using namespace std; ... // History.cpp #include "History.h" We define History::History, etc. #include "globals.h" We use MAXROBOTS, etc. #include <iostream> We use std::cout, etc. #include <cstdlib> We use std::exit using namespace std; ... // Player.cpp #include "Player.h" We define Player::Player, etc. #include "Arena.h" We use Arena::rows, etc. #include "History.h" We use History::record #include "globals.h" We use Dir, etc.
Image of page 3

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern