// Represents a square on the checkers board, for example A2, or B4 class position { }; friend class game_state: private: public: }; position (void); // Default constructor void from_text(const char *str); // Sets a position from a string char *to_text(void): bool is valid( void): void operator (const position &p): void offset(const int x, const int y): class move { private: Represents a move to be made // Put in your internal representation public: move(void): move( position &from position &to); void from_text(const char *str); charto_text(void): void set from(const position &from ): void set to const position &to); position &get_from(void); position &get_to(void): class game state ( private: // Allow game state to directly access private parts // Put in your internal representation Represents the state of a game public: // Converts the internal representation to a string // Returns true if the position is valid // Copies the contents of a position into this one // Offsets a position by x in the alpha value game state void ); game_stategame_state &g); // The types of pieces enum piece { EMPTY, RED PAWN, GREEN_PAWN, RED_KING, GREEN_KING }; // From two positions // Converts a string to a move // Gets either the starting // or ending position // Put in your internal representation // Sets the from using a position // Sets the to using a position // Default constructor // Default constructor // Copy constructor // Converts the internal representation to a string game_state(): void new game (void); bool is_game_over(void); // Check the game status bool is red turn (void): bool is green_turn (void); // String must be in the form "A4-B3" // and y in the numeric value // Destructor: do any tidying up required // Initialises state for the start of a new game

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Write classes for representing game state and move

Represents a square on the checkers board, for example A2, or B4
class position {
friend class game_state:
private:
public:
position (void):
// Default constructor
void from_text(const char *str); // Sets a position from a string
char* to_text(void);
// Put in your internal representation
bool is valid (void):
void operator =(const position &p):
void offset(const int x const int y);
Represents a move to be made
class move {
private:
// Allow game state to directly access private parts
public:
move(void):
move position &from position &to );
void from_text(const char *str);
char* to_text(void):
void set_from( const position &from );
void set to (const position &to);
position &get_from(void):
position &get_to(void):
// Put in your internal representation
// Represents the state of a game
class game state {
private:
public:
// Converts the internal representation to a string
// Returns true if the position is valid
// Copies the contents of a position into this one
// Offsets a position by x in the alpha value
// From two positions
// Converts a string to a move
// Gets either the starting
// or ending position
// The types of pieces
enum piece { EMPTY, RED_PAWN GREEN_PAWN, RED_KING, GREEN_KING };
game_state(void);
game state game_state &g);
game_state);
void new game (void);
bool is_game_over (void); // Check the game status
bool is_red_turn (void);
bool is green_turn (void);
// Put in your internal representation
// Sets the from using a position
// Sets the to using a position
// Default constructor
// Default constructor
// Converts the internal representation to a string
// Copy constructor
// String must be in the form "A4-B3"
// and y in the numeric value.
// Destructor: do any tidying up required
// Initialises state for the start of a new game
Transcribed Image Text:Represents a square on the checkers board, for example A2, or B4 class position { friend class game_state: private: public: position (void): // Default constructor void from_text(const char *str); // Sets a position from a string char* to_text(void); // Put in your internal representation bool is valid (void): void operator =(const position &p): void offset(const int x const int y); Represents a move to be made class move { private: // Allow game state to directly access private parts public: move(void): move position &from position &to ); void from_text(const char *str); char* to_text(void): void set_from( const position &from ); void set to (const position &to); position &get_from(void): position &get_to(void): // Put in your internal representation // Represents the state of a game class game state { private: public: // Converts the internal representation to a string // Returns true if the position is valid // Copies the contents of a position into this one // Offsets a position by x in the alpha value // From two positions // Converts a string to a move // Gets either the starting // or ending position // The types of pieces enum piece { EMPTY, RED_PAWN GREEN_PAWN, RED_KING, GREEN_KING }; game_state(void); game state game_state &g); game_state); void new game (void); bool is_game_over (void); // Check the game status bool is_red_turn (void); bool is green_turn (void); // Put in your internal representation // Sets the from using a position // Sets the to using a position // Default constructor // Default constructor // Converts the internal representation to a string // Copy constructor // String must be in the form "A4-B3" // and y in the numeric value. // Destructor: do any tidying up required // Initialises state for the start of a new game
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY