作业社区
探索学习新天地,共享知识资源!
满足各态历经性的XC 的学生作业:
#ifndef COMMON_H #define COMMON_H typedef char BYTE; typedef int INT; typedef short SHORT; typedef unsigned char WORD8; typedef unsigned short WORD16; typedef unsigned int WORD32; #endif // COMMON_H #ifndef CHESS_H #define CHESS_H #include “common.h” #include #include #include class Chess { private: INT x; INT y; std::string color; public: Chess(const std::string &color, INT x, INT y) : x(x), y(y), color(color) {} INT getx() const { return x; } INT gety() const; std::string getColor() const { return color; } virtual void show() const = 0; ~Chess(); }; Chess::~Chess() { } INT Chess::gety() const { return y; } #endif // CHESS_H #ifndef BLACK_CHESS_H #define BLACK_CHESS_H #include “common.h” #include “chess.h” #include class BlockChess : public Chess { public: BlockChess(INT x, INT y) : Chess(“black”, x, y) {} void show() const override; }; void BlockChess::show() const { fprintf(stderr, “\033[%d;%dH\033[43;35m[☻]\033[0m”, gety(), getx() - 1); fprintf(stderr, “\033[%d;%dH”, gety() + 1, getx()); } #endif // BLACK_CHESS_H #ifndef WHITE_CHESS_H #define WHITE_CHESS_H #include “common.h” #include “chess.h” #include class WhitekChess : public Chess { public: WhitekChess(INT x, INT y) : Chess(“black”, x, y) {} void show() const override; }; void WhitekChess::show() const { fprintf(stderr, “\033[%d;%dH\033[44;35m[☺]\033[0m”, gety(), getx() - 1); fprintf(stderr, “\033[%d;%dH”, gety() + 1, getx()); } #endif // BLACK_CHESS_H #include “blackchess.h” #include “whitechess.h” #include INT main() { BlockChess b(3, 4); WhitekChess w(6, 5); b.show(); w.show(); return 0; }