赞
踩
相关资料:http://t.csdn.cn/1XSne
实现目标:
目前进展:
主要用到就是射门概率那块,用随机数+能力值来控制
#include <iostream> #include "footballManager.h" FootballManager::FootballManager() { this->showMenu(); }; //FootballManager:: void FootballManager::exitSystem() { system("cls"); cout << "已成功退出,欢迎下次使用" << endl; system("pause"); } void FootballManager::showMenu() { cout << "-----------------------------------------------------" << endl; cout << " 英超联赛正在进行中,我是本场解说本泽马 " << endl; cout << "********** 1.开始本场比赛 **********" << endl; cout << "********** 2.查看英超积分排行榜 **********" << endl; cout << "********** 3.清空比赛记录 **********" << endl; cout << "********** 0.退出比赛程序 **********" << endl; cout << "-----------------------------------------------------" << endl; cout << endl; } //初始化球员姓名、能力 void FootballManager::initPlayer() { this->player.playerName = "Cristiano Ronaldo"; this->player.finsh = 95; this->player.number = 7; this->player.pass = 96; this->player.speed = 97; } //确定阵容 void FootballManager::detmineLineup() { cout << "本次双方阵容" << endl; cout << this->player.number << "号" << this->player.playerName << endl; } //比赛进行 void FootballManager::getScore() { int time = this->courtLength; while(time) { time -= this->player.speed - 90; if (time == this->courtLength - rand() % 30) { cout << this->player.playerName << " 准备射门了" << endl; break; } } this->player.shot(); } void FootballManager::changeBall() { cout << this->player.playerName << " 中路拿球" << endl; cout << this->player.playerName << " 快速带球" << endl; cout << this->player.playerName << " 全力冲刺" << endl; } //开始比赛 void FootballManager::startGame() { this->initPlayer(); this->detmineLineup(); this->changeBall(); this->getScore(); } FootballManager::~FootballManager() { };
#pragma once #include <iostream> #include "player.h" using namespace std; class FootballManager { public: int courtLength = 105, courtWidth = 68; Player player; FootballManager(); //交互界面 void showMenu(); //退出 void exitSystem(); //球员初始化 void initPlayer(); //确定阵容(初始化) void detmineLineup(); //比赛进行 void getScore(); //开球 void startGame(); //球权 void changeBall(); ~FootballManager(); };
#pragma once
#include <iostream>
using namespace std;
class Player
{
public:
Player();
string playerName;
int number;
int speed;
int finsh;
int pass;
void shot();
~Player();
};
#include "footballManager.h" #include <iostream> using namespace std; int main() { FootballManager fifa; int choice = 0; while (true) { cin >> choice; switch (choice) { case 1: fifa.startGame(); break; case 2: break; case 3: break; case 0: fifa.exitSystem(); return 0; break; default: system("cls"); break; } } system("pause"); return 0; }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。