第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定

作業(yè)社區(qū)

探索學習新天地,共享知識資源!

0 提交作業(yè)
0 布置作業(yè)
0 滿分作業(yè)
得分 100
學習任務

胡漢三66 的學生作業(yè):

Player.hpp #ifndef _PLAYER_HEAD_H #define _PLAYER_HEAD_H #include using namespace std; class Player{ // 抽象類 // 玩家類 public: Player(const string &name,const string &color){ // 構造函數(shù) this->name = name; this->color = color; } string getName(void) const{ // 獲取 玩家名字 return name; } string getColor(void) const{ // 獲取 棋子顏色 return color; } virtual bool placeChess(int x, int y) = 0; // 純虛函數(shù) // 判斷 落子位置 是否可以 保存棋子 private: string name; string color; }; #endif WhitePlayer.hpp #ifndef _WHITEPLAYER_HEAD_H #define _WHITEPLAYER_HEAD_H #include "Player.hpp" #include "ChessBoard.hpp" #include "WhiteChess.hpp" class WhitePlayer:public Player{ // 白棋玩家類 // 繼承 玩家類 public: WhitePlayer(const string &name):Player(name,"white"){} // 構造函數(shù) bool placeChess(int x,int y){ // 判斷 落子位置 是否可以 保存棋子 ChessBoard *chessBoard = ChessBoard::getChessBoard(); // 通過類函數(shù) 間接創(chuàng)建 棋盤對象 bool ok = chessBoard->isVaildPostion(x,y); // 判斷 落子位置 是否可以 保存棋子 if(ok){ chessBoard->placeChess(new WhiteChess(x,y)); // 如果可以 創(chuàng)建白棋對象 保存棋子 } return ok; } }; #endif BlackPlayer.hpp #ifndef _BLACKPLAYER_HEAD_H #define _BLACKPLAYER_HEAD_H #include "Player.hpp" #include "ChessBoard.hpp" #include "BlackChess.hpp" class BlackPlayer:public Player{ // 黑棋玩家類 // 繼承 玩家類 public: BlackPlayer(const string &name):Player(name,"black"){} // 構造函數(shù) bool placeChess(int x,int y){ // 判斷 落子位置 是否可以 保存棋子 ChessBoard *chessBoard = ChessBoard::getChessBoard(); // 通過類函數(shù) 間接創(chuàng)建 棋盤對象 bool ok = chessBoard->isVaildPostion(x,y); // 判斷 落子位置 是否可以 保存棋子 if(ok){ chessBoard->placeChess(new BlackChess(x,y)); // 如果可以 創(chuàng)建白棋對象 保存棋子 } return ok; } }; #endif main.cpp #include "BlackChess.hpp" // 黑棋 #include "WhiteChess.hpp" // 白棋 #include "ChessBoard.hpp" // 棋盤 #include "BlackPlayer.hpp" // 黑棋玩家 #include "WhitePlayer.hpp" // 白棋玩家 int main(int argc, const char *argv[]){ ChessBoard *chessBoard = ChessBoard::getChessBoard(); // 通過類函數(shù) 間接創(chuàng)建 棋盤對象 chessBoard->show(); // 打印棋盤 WhiteChess *whiteChess = new WhiteChess(5,7); // 創(chuàng)建 白棋對象 BlackChess *blackChess = new BlackChess(9,5); // 創(chuàng)建 黑棋對象 chessBoard->placeChess(whiteChess); // 棋盤 存放 白棋 chessBoard->placeChess(blackChess); // 棋盤 存放 黑棋 WhitePlayer *whitePlayer = new WhitePlayer("wdog"); // 創(chuàng)建 白棋玩家 whitePlayer->placeChess(9,5); // 白棋玩家 下棋 whitePlayer->placeChess(9,7); // 白棋玩家 下棋 BlackPlayer *blackPlayer = new BlackPlayer("bdog"); // 創(chuàng)建 黑棋玩家 blackPlayer->placeChess(5,7); // 黑棋玩家 下棋 blackPlayer->placeChess(13,5); // 黑棋玩家 下棋 return 0; } 【圖片】

得分 100
學習任務

胡漢三66 的學生作業(yè):

Chess.hpp #ifndef _CHESS_H_ #define _CHESS_H_ #include using namespace std; class Chess{ // 抽象類 public: Chess(const string &color,int x,int y):color(color),x(x),y(y){} // 構造函數(shù) int getX(void) const{ return x; } // 返回 坐標點 x int getY(void) const{ return y; } // 返回 坐標點 y string getColor(void) const{ return color;} // 返回 棋子顏色 virtual void show(void) const = 0; // 純虛函數(shù) private: int x; // 坐標 x int y; // 坐標 y string color; // 棋子顏色 }; #endif BlackChess.hpp #ifndef _BLACKCHESS_H_ #define _BLACKCHESS_H_ #include #include "Chess.hpp" class BlackChess:public Chess { // 繼承類 Chess 的公有成員 public: BlackChess(int x,int y):Chess("black",x,y){} // 構造函數(shù) void show(void) const{ fprintf(stderr,"\033[%d;%dH\033[44;31m[? ]\033[0m",getY(),getX() - 1); // 棋子坐標 // 藍底紅字 棋子[? ] // 關閉所有屬性 fprintf(stderr,"\033[%d;%dH\n",getY(),getX()); // 定義在棋子中心左側 // 每個棋子寬度占3個符號 } }; #endif WhiteChess.hpp #ifndef _WHITECHESS_H_ #define _WHITECHESS_H_ #include #include "Chess.hpp" class WhiteChess:public Chess { // 繼承類 Chess 的公有成員 public: WhiteChess(int x,int y):Chess("white",x,y){} // 構造函數(shù) void show(void) const{ fprintf(stderr,"\033[%d;%dH\033[43;37m[? ]\033[0m",getY(),getX() - 1); // 棋子坐標 // 黃底白字 棋子 : [? ] // 關閉所有屬性 fprintf(stderr,"\033[%d;%dH\n",getY(),getX()); // 定義在棋子中心左側 // 每個棋子寬度占3個符號 } }; #endif main.cpp #include "BlackChess.hpp" #include "WhiteChess.hpp" int main(int argc, const char *argv[]){ WhiteChess w(5,6); BlackChess b(9,6); w.show(); b.show(); return 0; } 【圖片】

微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號