IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> C++知识库 -> 基于c++的MUD小游戏 -> 正文阅读

[C++知识库]基于c++的MUD小游戏

c++MUD小游戏? ? 游戏人生? 文字游戏

这个游戏使我们小组合作完成的,在此给各位入门玩家借鉴,相信我一定要自己看懂,内容逻辑一定要懂!!!!

游戏名字为《游戏人生》,类似于人生模拟器,但这个只是用于学生时代,内容真实,相信每个有点故事的人都经历过!哈哈哈哈哈哈

人物有? ?超级学霸? 网瘾少年? 体育生? 三个角色供选择!

你可以挑选你喜欢的角色进行你的游戏人生,每个人的天赋点都不同,并且每个人进行的活动所带来的收益也不同!!

话不多说 先上代码!!

?这是个总览

#ifndef Activity_H
#define Activity_H
#include "Guy.h"

class Activity :public Guy
{
public:
	Activity();//空构造函数
	Activity(const Guy &person);//用Guy类创建一个场景类
	Activity(const Activity &person);//拷贝函数
	virtual ~Activity();//析构函数

	int inputtime();//时间输入函数,判断是否合法
	int judgetime(int hour);//判断是否熬夜  0不熬 1熬夜
	int inputplaytime(int price);//输入游玩时间
	int random_machine(int num);//产生随机概率,1/num
	void internetbar_event();//网吧的随机事件
	void welcom_to_park();//公园的标语
	void park_event();//公园的随机事件
	void homerandom_event(); //家中可能发生的随机事件
	void shopmenu();//商场菜单

	void internetbar();//去网吧
	void park();//去公园
	void gym();//健身房
	void home();//家
	void shop();//商店
	void school();//学校

};

#endif

?以下是Activity.cpp文件

?内容有点多哈哈哈? ? 正是为了让游戏更有可玩性? ?

#include <iostream>
#include <Windows.h>
#include <ctime>
#include "Activity.h"
using namespace std;

Activity::Activity() :Guy()  //空构造函数
{

}

Activity::Activity(const Guy &person) : Guy(person)//用Guy类创建一个场景类
{

}

Activity::Activity(const Activity &person)//拷贝构造函数
{
	IQ = person.IQ;
	build = person.build;
	satisfaction = person.satisfaction;
	pressure = person.pressure;
	money = person.money;
	times = person.times;
	job = person.job;
	day = person.day;
	playday = person.playday;
}

Activity::~Activity()//析构函数
{

}

int Activity::inputtime()//时间输入函数,并判断是否合法
{
	int hour = 0;
	cin >> hour;
	while (hour + times > 24)//输入不合法要重新输入
	{
		cout << "输入不合法要重新输入:";
		cin >> hour;
	}
	return hour;
}

int Activity::inputplaytime(int price)//输入游玩时间,并判断钱是否够
{
	int hour = 0;
	cin >> hour;
	while (hour * price > money || hour + times > 24)//钱不够或输入不合法
	{
		if (hour * price > money && hour + times > 24)
		{
			cout << "你的钱不够并且输入不合法,请重新输入时间:";
			cin >> hour;
		}
		else if (hour * price > money)
		{
			cout << "你的钱不够,请重新输入时间:";
			cin >> hour;
		}
		else
		{
			cout << "输入不合法要重新输入:";
			cin >> hour;
		}
	}
	return hour;
}

int Activity::judgetime(int hour)//判断是否熬夜  0不熬 1熬夜(返回超过的时间)
{
	int virtualtimes = times + hour;//虚拟的时间,用于判断是否熬夜
	if (virtualtimes > 12)//熬夜
		return virtualtimes - 12;
	else  //不熬夜 
		return 0;
}

int Activity::random_machine(int num)//产生随机概率,1/num,返回1发生,0不发生
{
	srand((unsigned int)time(0));//随机数
	int number = rand() % num;//产生0到num之间的随机数
	if (number == 0)
	{
		return 1;//发生
	}
	else
		return 0;//不发生
}

void Activity::internetbar_event()//网吧的随机事件
{
	srand((unsigned int)time(0));//随机数
	int parent_catch = random_machine(5);//被家长逮到  1/10
	if (parent_catch == 1)
	{
		cout << endl;
		cout << "_______________________________________" << endl;
		cout << " !!!你上网吧被家长逮到了!!! w(゚Д゚)w" << endl;
		if (job == 1)//学霸
		{
			int satisfaction_declin = 15 + rand() % 6;
			satisfaction = satisfaction - satisfaction_declin;//好感度减15-20
			cout << "家长:这段时间成绩倒退,原来是上网吧了! (;′⌒`)" << endl;
			cout << "——父母好感度减少:" << satisfaction_declin << endl;
		}
		if (job == 2)//体育生
		{
			int satisfaction_declin = 10 + rand() % 6;
			satisfaction = satisfaction - satisfaction_declin;//好感度减10-15
			cout << "家长:不好好学习,竟然上网吧 ?!! o( ̄ヘ ̄o#)" << endl;
			cout << "——父母好感度减少:" << satisfaction_declin << endl;
		}
		if (job == 3)//网瘾少年
		{
			cout << "家长:。。。 (ーー゛)" << endl;
			cout << "父母对于你上网吧已经习以为常." << endl;
			cout << "——父母好感度减少:0" << endl;
		}
		cout << "_______________________________________" << endl << endl;
	}
	
	int rob = random_machine(5);//被打劫 1/10
	if (rob == 1 && job != 3)//网瘾少年不会被打劫
	{
		cout << "____________________________________" << endl;
		cout << " WC! !!遇到打劫的了 !!! ┌(。Д。)┐" << endl << endl;
		cout << "混混:Hey Bro!借点钱上网 ( ﹁ ﹁ ) ~→" << endl;
		cout << "你可以选择:1.乖乖交出钱     2.逃跑 " << endl;
		int choice;
		cin >> choice;
		while (choice != 1 && choice != 2)//不合法重输
		{
			cout << "输入不合法要重新输入:";
			cin >> choice;
		}
		cout << endl;
		int decide = random_machine(2);//1/2概率逃跑成功
		if (choice == 2 && decide == 1)
		{
			cout << "逃跑成功!!!(??????)??" << endl;
		}
		else if (choice == 2 && decide == 0)
		{
			cout << "逃跑失败!!!你被拉回来打了一顿,并且抢了你的钱! X﹏X" << endl;
			int money_declin = money * 0.2;
			money = money - money_declin;
			build = build - 2;
			IQ = IQ - 0.3;
			cout << "——被打劫了" << money_declin << "元" << endl;
			cout << "——体魄减少" << 2 << endl;
			cout << "——智商减少" << 0.3 << endl;
		}
		else if (choice == 1)
		{
			int money_declin = money * 0.2;
			money = money - money_declin;
			cout << "——被打劫了" << money_declin << "元" << endl;
		}
		cout << "____________________________________" << endl << endl;
	}
}

void Activity::welcom_to_park()//公园的标语
{
	srand((unsigned int)time(0));//随机数
	int choice = rand() % 6;
	if (choice == 0)
	{
		cout << "公园里草木茂盛,草碧绿碧绿,像一片葱郁的绿毯。有各种各样的花在开放,紫色、红色、蓝色、绿色、黄色……真是五彩缤纷。" << endl;
	}
	if (choice == 1)
	{
		cout << "公园里天空高远,阳光柔和,蔚蓝的天空上飘着几片薄纱似的白云。耳边响着一阵阵清脆的鸟鸣声,好像是大自然在歌唱。" << endl;
	}
	if (choice == 2)
	{
		cout << "公园里有绿地毯似的草坪,夕阳穿过数木,印出了树影,有深有浅,美丽极了!" << endl;
	}
	if (choice == 3)
	{
		cout << "公园里有弯弯的小路,有尖角的亭子,有圆圆的花坛,尤其然而明镜似的池塘,使它更加吸引人注目。" << endl;
	}
	if (choice == 4)
	{
		cout << "公园里的小草偷偷地从土里钻出来,嫩嫩的,绿绿的。瞧去,一大片一大片满是的。风轻悄悄的,草绵软软的。" << endl;
	}
	if (choice == 5)
	{
		cout << "公园里天上风筝渐渐多了,地上孩子也多了。家家户户,老老小小,他们也赶趟儿似的,一个个都出来了。舒活舒活筋骨,抖擞抖擞精神。" << endl;
	}
}

void Activity::park_event()//公园随机事件
{
	srand((unsigned int)time(0));//随机数
	int pick_money = random_machine(7);// 1/7概率捡钱
	if (pick_money == 1)
	{
		int illicit_money;
		illicit_money = 50 + rand() % 20;//捡50——70元
		cout << "__________________________________________" << endl;
		cout << "捡到了" << illicit_money << "元!!!⊙▽⊙" << endl;
		cout << "1.把钱交给警察叔叔      2.暂时保管到自己口袋( ﹁ ﹁ )" << endl;
		cout << "请选择:";
		int choice;
		cin >> choice;
		while (choice != 1 && choice != 2)//不合法重输
		{
			cout << "输入不合法要重新输入:";
			cin >> choice;
		}
		if (choice == 1)
		{
			cout << "真是拾金不昧的好孩子!(づ ̄3 ̄)" << endl;
			satisfaction = satisfaction + 8;
			cout << endl << "——父母满意度增加" << 8 << endl;
		}
		if (choice == 2)
		{
			money = money + illicit_money;
			cout << "——金钱增加:" << illicit_money << "元" << endl;
		}
		cout << "__________________________________________" << endl << endl;
	}
	int through_around = random_machine(5);//1/10概率有人乱丢垃圾
	if (through_around == 1)
	{
		cout << "______________________________________" << endl;
		cout << "有人在乱丢垃圾!!" << endl;
		cout << "请选择:" << endl;
		cout << "1.捡起来,并且悉心劝导他      2.不关我事" << endl;
		int choice;
		cin >> choice;
		while (choice != 1 && choice != 2)//不合法重输
		{
			cout << "输入不合法要重新输入:";
			cin >> choice;
		}
		if (choice == 1)
		{
			cout << "今天也是为环保做贡献的一天!!!<( ̄︶ ̄)>" << endl;
			satisfaction = satisfaction + 3;
			cout << endl << "——父母满意度增加" << 3 << endl;
		}
		cout << "______________________________________" << endl << endl;
	}
	int help = random_machine(5);//过马路
	if (help == 1)
	{
		cout << "__________________________________" << endl;
		cout << "有老奶奶正在过马路!!" << endl;
		cout << "请选择:" << endl;
		cout << "1.扶老奶奶过马路      2.下次一定" << endl;
		int choice;
		cin >> choice;
		while (choice != 1 && choice != 2)//不合法重输
		{
			cout << "输入不合法要重新输入:";
			cin >> choice;
		}
		if (choice == 1)
		{
			cout << "老奶奶:谢谢你啊,小伙子!(*^▽^*)" << endl;
			satisfaction = satisfaction + 3;
			cout << endl << "——父母满意度增加" << 3 << endl;
		}
		cout << "__________________________________" << endl << endl;
	}
}

void Activity::shopmenu()//商场的菜单栏
{
	printf("您好! Master\n");
	printf("欢迎来到莓啥用商店\n");
	printf("以下是本店的产品:\n");
	printf("==============================================================\n");
	printf("1.      5+3        价格:50元    \n");
	printf("2. 体育竞赛报名表  价格:65元    \n");
	printf("3.   父母快乐水    价格:100元   \n");
	printf("4.     尖叫鸡      价格:30元    \n");
	printf("==============================================================\n");
	printf("您当前拥有的RMB为%g元,请通过产品前面的数字进行操作\n", money);
	printf("\n");
	printf("若要离开本店,请输入数字5\n");
	printf("Master,您的选择是:");
}

void Activity::internetbar()//去网吧
{

	cout << endl << "~~~~~~~~~~~~~~~" << endl;
	cout << "      网吧     " << endl;
	cout << endl;
	cout << "~~~~~~~~~~~~~~~" << endl;
	if (times >= 12 || money < 10)
	{
		if (times >= 12)
		{
			cout << "网吧打烊了,明天再来吧" << endl;
		}
		else
		{
			cout << "你的钱已经不够在这里玩一小时,请获得足够的钱再来" << endl;
		}
		cout << endl;
		system("pause");
	}
	else
	{
		cout << "欢迎来到网吧,这里是减压的好去处,但是可能会有意外发生......" << endl << endl;
		int hour;
		cout << "请输入上网时间(¥10/h):";
		hour = inputplaytime(10);
		int beyondtimes = judgetime(hour);//超出的时间

		if (beyondtimes) //时间超过12h
		{
			cout << endl;
			cout << "————————————————————————" << endl;
			cout << "网吧夜间不开放!" << endl;
			cout << "请选择:" << endl;
			cout << "1.玩到网吧关门      2.离开网吧" << endl;
			cout << "————————————————————————" << endl;
			int choice;
			cin >> choice;
			while (choice != 1 && choice != 2)//不合法重输
			{
				cout << "输入不合法要重新输入:";
				cin >> choice;
			}
			if (choice == 1)
			{
				internetbar_event();//随机事件
				int playtimes = 12 - times;
				cout << endl << "——已在网吧玩" << playtimes << "小时——" << endl;
				pressure = pressure - playtimes * 1;//减压
				money = money - playtimes * 10;//扣钱
				times = times + playtimes;//加时间
				cout << "——压力减少:" << playtimes << endl;
				cout << "——消费:" << playtimes * 10 << "元" << endl;
				cout << endl << "按任意键离开网吧" << endl;
			}
			if (choice == 2)
			{
				cout << endl << "已经离开网吧!";
			}
		}
		else//时间不超过12h
		{
			internetbar_event();//随机事件
			cout << endl << "——已在网吧玩" << hour << "小时——" << endl;
			pressure = pressure - hour * 1;//减压
			money = money - hour * 10;//扣钱
			times = times + hour;//加时间
			cout << "——压力减少:" << hour * 1 << endl;
			cout << "——消费:" << hour * 10 << "元" << endl;
			cout << endl << "按任意键离开网吧" << endl;
		}
		system("pause");
	}
}

void Activity::park()//去公园
{

	cout << endl << "~~~~~~~~~~~~~~~" << endl;
	cout << "      公园     " << endl << endl;
	cout << "~~~~~~~~~~~~~~~" << endl;
	welcom_to_park();//标语
	cout << endl;
	if (times >= 12)
	{
		cout << "公园关门了,明天再来吧" << endl;
		system("pause");
	}
	else
	{
		cout << "请输入游玩时间:";
		int hour = inputtime();//输入时间
		int beyondtimes = judgetime(hour);//超出的时间

		if (beyondtimes)
		{
			cout << endl;
			cout << "————————————————————————" << endl;
			cout << "公园夜间不开放!" << endl;
			cout << "请选择:" << endl;
			cout << "1.玩到公园关门      2.离开公园" << endl;
			cout << "————————————————————————" << endl;
			int choice;
			cin >> choice;
			while (choice != 1 && choice != 2)//不合法重输
			{
				cout << "输入不合法要重新输入:";
				cin >> choice;
			}
			if (choice == 1)
			{
				park_event();//随机事件
				int playtimes = 12 - times;
				cout << endl << "——已在公园玩" << playtimes << "小时——" << endl;
				pressure = pressure - playtimes * 0.5;//减压
				times = times + playtimes;//加时间
				cout << "——压力减少:" << playtimes * 0.5 << endl;
				cout << endl << "按任意键离开公园" << endl;
			}
			if (choice == 2)
			{
				cout << "已经离开公园!" << endl;
			}
		}
		else//时间不超过12h
		{
			park_event();//随机事件
			cout << "——已在公园玩" << hour << "小时——" << endl;
			pressure = pressure - hour * 0.5;//减压
			times = times + hour;//加时间
			cout << "——压力减少:" << hour * 0.5 << endl;
			cout << endl << "按任意键离开公园" << endl;
		}
		system("pause");
	}
}

void Activity::gym()//健身房函数
{

	cout << "------------------------------------------------------" << endl;
	cout << "                        健身房                        " << endl;
	cout << "------------------------------------------------------" << endl;
	cout << "                                                                             " << endl;
	cout << "(温馨提醒:你已到达健身房。)" << endl;
	cout << "                                                                             " << endl;
	if (times >= 12 || money < 25)
	{
		if (times >= 12)
		{
			cout << "健身房打烊了,明天再来吧" << endl;
		}
		else
		{
			cout << "你的钱已经不够在这里玩一小时,请获得足够的钱再来" << endl;
		}
		system("pause");
	}
	else
	{
		int hour; //健身的时间
		double cost; //健身房的消费额
		cout << "欢迎来到健身房,本健身房的价格为每小时25元,请输入您要健身的时间:";
		hour = inputplaytime(25);
		int beyondtime = judgetime(hour);//超出的时间
		if (beyondtime) //时间超过12h
		{
			cout << "健身房夜间不开放!" << endl;
			cout << "请输入你的选择:";
			cout << "1.健身至健身房关门    2.离开健身房" << endl;
			int choice;
			cin >> choice;
			while (choice != 1 && choice != 2)//不合法重输
			{
				cout << "输入不合法要重新输入:";
				cin >> choice;
			}

			if (choice == 1)
			{
				int buildtime = 12 - times;  //已健身时间
				cost = buildtime * 10;//健身消费额
				cout << "已健身" << buildtime << "小时!" << endl;
				cout << "健身房即将打烊,请离开健身房,谢谢您的配合!" << endl;
				cout << "你已经离开健身房!" << endl;
				money = money - cost;//剩余钱数
				times = 12;
				cout << "                                                                             " << endl;
				switch (job)       //根据角色确定增加的体魄
				{
				case 1: build = build + 1 * buildtime; //学霸
					cout << "此次健身你共消费" << cost << "元!" << endl;
					cout << "此次健身你的体魄增加了" << buildtime << "点!" << endl;   break;
				case 2: build = build + 2 * buildtime; //体育生
					cout << "此次健身你共消费" << cost << "元!" << endl;
					cout << "此次健身你的体魄增加了" << buildtime * 2 << "点!" << endl;  break;
				case 3: build = build + 1 * buildtime; //网瘾少年
					cout << "此次健身你共消费" << cost << "元!" << endl;
					cout << "此次健身你的体魄增加了" << buildtime << "点!" << endl;
				}


			}
			if (choice == 2)
			{
				cout << "你已经离开健身房!" << endl;
			}
		}


		else   //不超时
		{
			cost = hour * 25;    //消费额
			money = money - cost;  //剩余钱数
			times = times + hour;  //消耗时间
			cout << "您的健身已经完成,欢迎下次光临!" << endl;
			cout << "                                                                             " << endl;
			switch (job)       //根据角色确定增加的体魄
			{
			case 1: build = build + 1 * hour;
				cout << "此次健身你共消费" << cost << "元!" << endl;
				cout << "此次健身你的体魄增加了" << hour << "点!" << endl;   break;
			case 2: build = build + 2 * hour;
				cout << "此次健身你共消费" << cost << "元!" << endl;
				cout << "此次健身你的体魄增加了" << hour * 2 << "点!" << endl;   break;
			case 3: build = build + 1 * hour;
				cout << "此次健身你共消费" << cost << "元!" << endl;
				cout << "此次健身你的体魄增加了" << hour * 2 << "点!" << endl;
			}



		}

		system("pause");
	}
}

void Activity::home()//家函数
{

	cout << "------------------------------------------------------" << endl;
	cout << "                        家                            " << endl;
	cout << "------------------------------------------------------" << endl;
	cout << "                                                                             " << endl;
	cout << "(温馨提醒:你已回到家中。)" << endl;
	cout << "                                                                             " << endl;
	homerandom_event();  //随机事件,若发生消耗1小时
	cout << "你当前在家中,请选择你要做的事情: 1.睡觉  2.学习  " << endl;
	int choice;
	cin >> choice;
	while (choice != 1 && choice != 2)
	{
		cout << "输入不合法,请重新输入!" << endl;
		cin >> choice;
	}

	if (choice == 1)
	{
		pressure = pressure - 0.5;
		cout << "你已进入睡眠状态,压力减少0.5点!" << endl;
		times = 24;
	}

	if (choice == 2)
	{
		int hour;//你要学习的时间
		int beyondtime;//临时变量,用于判断是否熬夜
		cout << "你选择进行学习,请输入你要学习的时间:";
		hour = inputtime();//判断学习时间是否合法
		beyondtime = judgetime(hour);//判断是否熬夜
		if (beyondtime == 0)   //正常学习然后摸鱼,不熬夜
		{
			cout << "您正在学习中,你要学习的时间为" << hour << "小时。" << endl;
			cout << "您已学习" << hour << "小时!" << endl;
			//在家正常学习的效果为在学校的80%,根据角色确定增加的智力
			switch (job)
			{
			case 1: IQ = IQ + 0.8 * 0.1 * hour; //学霸
				cout << "经过此次学习,你的智力增加了" << 0.8 * 0.1 * hour << "点!" << endl;    break;
			case 2: IQ = IQ + 0.8 * 0.05 * hour; //体育生
				cout << "经过此次学习,你的智力增加了" << 0.8 * 0.05 * hour << "点!" << endl;   break;
			case 3: IQ = IQ + 0.8 * 0.08 * hour; //网瘾少年
				cout << "经过此次学习,你的智力增加了" << 0.8 * 0.08 * hour << "点!" << endl;   break;
			}

			//摸鱼每小时减0.1压力

			if (hour + times == 12)
			{
				cout << "你今天的工作时间已达上限,将进入睡眠状态!" << endl;
			}

			if (hour + times != 12)
			{
				pressure = pressure - (12 - hour)*0.1;
				cout << "剩余" << 12 - times - hour << "小时将自动摸鱼。" << endl;
				cout << "摸鱼结束!" << "经过此次摸鱼,你的压力减少了" << (12 - hour)*0.1 << "点!请及时睡觉!" << endl;
			}

			//摸完鱼睡觉,睡觉压力减0.5
			pressure = pressure - 0.5;
			cout << "你已进入睡眠状态,压力减少0.5点!一天到此结束!" << endl;
			times = 24; //学完习之后睡觉,一天结束


		}

		if (beyondtime)  //学习超时,熬夜
		{
			cout << "你要学习的时间过长,需要熬夜,请再次选择是否要熬夜学习:"<<endl;
			cout << "1.学习至12小时后睡觉  2.保持原有学习时间 " << endl;
			cout << "请选择:";
			int option;
			cin >> option;
			while (option != 1 && option != 2)
			{
				cout << "输入不合法,请重新输入!" << endl;
				cin >> option;
			}


			if (option == 1) //学习至12小时后睡觉
			{
				int studytime = 12 - times; //学习时间
				cout << "您正在学习中,你要学习的时间为" << studytime << "小时 " << endl;
				//在家正常学习的效果为在学校的80%,根据角色确定增加的智力
				switch (job)
				{
				case 1: IQ = IQ + 0.8 * 0.1 * studytime; //学霸
					cout << "您的学习已完成,智力增加" << 0.8 * 0.1 * studytime << "点!同时你今天的学习时间已达上限,将进入睡眠状态!" << endl;   break;
				case 2: IQ = IQ + 0.8 * 0.05 * studytime; //体育生
					cout << "您的学习已完成,智力增加" << 0.8 * 0.05 * studytime << "点!同时你今天的学习时间已达上限,将进入睡眠状态!" << endl;   break;
				case 3: IQ = IQ + 0.8 * 0.08 * studytime; //网瘾少年
					cout << "您的学习已完成,智力增加" << 0.8 * 0.05 * studytime << "点!同时你今天的学习时间已达上限,将进入睡眠状态!" << endl;
				}

				// 觉压力减0.5
				pressure = pressure - 0.5;
				cout << "                                                                             " << endl;
				cout << "您已进入睡眠状态,压力减少0.5点!" << endl;
				times = 24; //学完习之后睡觉,一天结束
			}


			else
			{
				//熬夜学习,体魄每小时减1,压力每小时加1
				int studytime = hour - beyondtime;
				pressure = pressure + beyondtime * 1;
				build = build - beyondtime * 1;
				cout << "你将继续进行学习" << hour << "小时!" << endl;
				system("cls");
				cout << "                                                                             " << endl;
				cout << "你已学习" << hour << "小时!" << endl;
				cout << "                                                                             " << endl;
				//在家正常学习的效果为在学校的80%,熬夜学习的效果为学校的50%
				// 根据角色确定增加的智力
				switch (job)
				{
				case 1: IQ = IQ + 0.8 * 0.1 * studytime + 0.5 * 0.1 * beyondtime; //学霸
					cout << "你的学习已完成,将进入睡觉状态!此次学习你的属性变化如下:" << endl;
					cout << "你的智力增加" << 0.8 * 0.1 * studytime + 0.5 * 0.1 * beyondtime << "点!" << endl;
					cout << "压力增加" << beyondtime << "点!" << endl;
					cout << "体魄减少" << beyondtime << "点!" << endl;   break;
				case 2: IQ = IQ + 0.8 * 0.05 * studytime + 0.5 * 0.05 * beyondtime; //体育生
					cout << "你的学习已完成,将进入睡觉状态!此次学习你的属性变化如下:" << endl;
					cout << "你的智力增加" << 0.8 * 0.05 * studytime + 0.5 * 0.05 * beyondtime << "点!" << endl;
					cout << "压力增加" << beyondtime << "点!" << endl;
					cout << "体魄减少" << beyondtime << "点!" << endl;   break;
				case 3: IQ = IQ + 0.8 * 0.08 * studytime + 0.5 * 0.08 * beyondtime; //网瘾少年
					cout << "你的学习已完成,将进入睡觉状态!此次学习你的属性变化如下:" << endl;
					cout << "你的智力增加" << 0.8 * 0.08 * studytime + 0.5 * 0.08 * beyondtime << "点!" << endl;
					cout << "压力增加" << beyondtime << "点!" << endl;
					cout << "体魄减少" << beyondtime << "点!" << endl;
				}

				cout << "                                                                             " << endl;
				// 觉压力减0.5
				pressure = pressure - 0.5;
				cout << "您已进入睡眠状态,压力减少0.5点!" << endl;
				times = 24; //学完习之后睡觉,一天结束
			}


		}


	}

	system("pause");

}


void Activity::homerandom_event()  //家中可能发生的随机事件
{
	srand((unsigned int)time(0));//随机数

	if (12 - times >= 3)     //如果剩余工作时间大于等于3个小时,则可能发生随机事件
	{
		//随机事件一:父母要求你帮忙做家务
		int  housework_flag = random_machine(5);   //判断该随机事件是否发生,该事件概率为1/5,若为1则发生,0则不发生
		if (housework_flag == 1)  //该随机事件发生
		{
			int option;
			cout << "你回到家中,父母让你帮忙做家务,是否帮忙做家务?" << endl;
			cout << "  1.是			2.否 " << endl;
			cin >> option;
			if (option == 1)
			{
				cout << "你正在做家务!" << endl;
				cout << "一小时之后,你做完了家务。" << endl;
				//做家务完成,满意度增加,金钱增加
				//满意度基础增加为5,可额外增加0-2
				double random_satisfaction_increase = rand() % 2;  //另外随机的满意度增加
				satisfaction = satisfaction + 5 + random_satisfaction_increase;
				//金钱基础增加为30,可随机额外增加0-5
				double random_money_increase = rand() % 5;    //另外随机的金钱增加
				money = money + 30 + random_money_increase;
				cout << "你的家务做的不错,你母亲奖励你" << 30 + random_money_increase << "元。" << endl;
				cout << "你的金钱增加" << 30 + random_money_increase << "元!" << endl;
				cout << "你的满意度增加" << 5 + random_satisfaction_increase << "点!" << endl;
				cout << "                                                                             " << endl;
				times++;  //做家务耗时一小时
			}

			if (option == 2)
			{
				satisfaction = satisfaction - 10;
				cout << "由于你不帮父母做家务,父母很生气,对你的满意度降低了10点!" << endl;
				cout << "                                                                             " << endl;
			}
		}

		//随机事件二:家中来客人,父母让你帮忙招待
		int  treatment_flag = random_machine(8);   //判断该随机事件是否发生,该事件概率为1/8,若为1则发生,0则不发生
		if (treatment_flag == 1 && housework_flag != 1)
		{
			cout << "你的叔叔阿姨就要来了,父母让你帮忙招待叔叔阿姨你。" << endl;
			cout << "请选择是否认真帮忙:1.敷衍帮忙  2.认真帮忙 " << endl;
			int choice; //用于你的选择
			cin >> choice;
			if (choice == 1)
			{
				satisfaction = satisfaction - 5;
				cout << "两个小时之后,客人走了。" << endl;
				cout << "在客人走后,你的父母训斥了你,你的父母满意度降低了5点!" << endl;
				int random_decrease = rand() % 5; //随机降低的满意度
				satisfaction = satisfaction - random_decrease;
				cout << "你的父母因为工作很累,加之你招待不周,又额外降低了" << random_decrease << "点满意度!" << endl;
				cout << "                                                                             " << endl;
			}

			if (choice == 2)  //招待很好,父母满意度增加
			{
				satisfaction = satisfaction + 10;   //招待很好,满意度加10
				int random_increase = rand() % 5; //随机增加的满意度
				satisfaction = satisfaction + random_increase;
				cout << "你认真招待客人,两个小时后,客人离开了。" << endl;
				cout << "由于你招待客人很好,增加了" << 10 + random_increase << "父母满意度!" << endl;
				cout << "                                                                             " << endl;
				times = times + 2; //招待客人耗费两小时
			}
		}
	}
}


void Activity::shop()//商场
{
	int n = 1;
	while (n == 1)
	{
		system("cls");
		shopmenu();

		int num;
		cin >> num;
		//输入的容错
		while (num != 1 && num != 2 && num != 3 && num != 4 && num != 5)
		{
			printf("亲,你的输入不合法,请重新且认真地输入。\n");
			printf("那么,这一次你的选择是:");
			cin >> num;
		}
		//退出
		if (num == 5)
		{
			n = 0;
			system("cls");
		}
		//5+3的介绍栏
		if (num == 1)
		{
			system("cls");
			printf("-------------------------------------------------\n");
			printf("\n");
			printf("    5+3     功能:智力+1\n");
			printf("\n");
			printf("    1.购买     2.取消\n");
			printf("\n");
			printf("-------------------------------------------------\n");
			printf("那么,您的选择是:");
			int number;
			cin >> number;
			if (number == 1 && money >= 50)
			{
				IQ = IQ + 1;
				money = money - 50;
			}
			else if (number == 1 && money < 50)
			{
				system("cls");
				printf("##########################################\n");
				printf("\n");
				printf("抱歉,您的RMB不足以购买这件产品\n");
				printf("\n");
				printf("##########################################\n");
				system("pause");
			}
			if (number == 2)
			{
				continue;
			}
		}
		//体育竞赛报名表的介绍栏
		if (num == 2)
		{
			system("cls");
			printf("-------------------------------------------------\n");
			printf("\n");
			printf("    体育竞赛报名表     功能:体魄+2\n");
			printf("\n");
			printf("    1.购买     2.取消\n");
			printf("\n");
			printf("-------------------------------------------------\n");
			printf("那么,您的选择是:");
			int number;
			cin >> number;
			if (number == 1 && money >= 65)
			{
				build = build + 2;
				money = money - 65;
			}
			else if (number == 1 && money < 65)
			{
				system("cls");
				printf("##########################################\n");
				printf("\n");
				printf("抱歉,您的RMB不足以购买这件产品\n");
				printf("\n");
				printf("##########################################\n");
				system("pause");
			}
			if (number == 2)
			{
				continue;
			}
		}
		//父母快乐水的介绍栏
		if (num == 3)
		{
			system("cls");
			printf("-------------------------------------------------\n");
			printf("\n");
			printf("    父母快乐水   功能:父母满意度+3\n");
			printf("\n");
			printf("    1.购买     2.取消\n");
			printf("\n");
			printf("-------------------------------------------------\n");
			printf("那么,您的选择是:");
			int number;
			cin >> number;
			if (number == 1 && money >= 100)
			{
				satisfaction = satisfaction + 3;
				money = money - 100;
			}
			else if (number == 1 && money < 100)
			{
				system("cls");
				printf("##########################################\n");
				printf("\n");
				printf("抱歉,您的RMB不足以购买这件产品\n");
				printf("\n");
				printf("##########################################\n");
				system("pause");
			}
			if (number == 2)
			{
				continue;
			}
		}
		//尖叫鸡的介绍栏
		if (num == 4)
		{
			system("cls");
			printf("-------------------------------------------------\n");
			printf("\n");
			printf("    尖叫鸡     功能:压力-2\n");
			printf("\n");
			printf("    1.购买     2.取消\n");
			printf("\n");
			printf("-------------------------------------------------\n");
			printf("那么,您的选择是:");
			int number;
			cin >> number;
			if (number == 1 && money >= 30)
			{
				pressure = pressure - 2;
				money = money - 30;
			}
			else if (number == 1 && money < 30)
			{
				system("cls");
				printf("##########################################\n");
				printf("\n");
				printf("抱歉,您的RMB不足以购买这件产品\n");
				printf("\n");
				printf("##########################################\n");
				system("pause");
			}
			if (number == 2)
			{
				continue;
			}
		}

	}
}


void Activity::school()//去学校
{
	times += 6;
	system("cls");
	printf("================================================================================\n");
	printf("欢迎来到史莱克学院,陌生人\n");
	printf("你一共有6个小时可以用在本学院\n");
	printf("另外,本学院仅提供学习和摸鱼服务\n");
	printf("而本学院宗旨是——只教怪物,不教普通人\n");
	printf("因此,确定学习的时间后剩余的时间会默认为摸鱼时间\n");
	printf("PS:本学院的优良传统,仅仅是策划没带脑造成的。正所谓冤有头......\n");
	printf("================================================================================\n");
	int hour;
	printf("那么,陌生的怪物。你纠结出的学习时间为:");
	cin >> hour;
	system("cls");
	//输入的容错
	while (hour > 6 || hour < 0)
	{
		printf("嘿!你的输入违法啦!\n");
		printf("粗心的怪物,这一次你的学习时间是:");
		cin >> hour;
		if (hour > 6 || hour < 0)
		{
			system("cls");
			printf("额,你故意的吧!\n");
			printf("再给你最后一次机会,请务必把握好!\n");
			system("pause");
			printf("\n");
			printf("另外,我可以诚实地告诉你,再错也没有这样有趣的对话了。真的!\n");
			printf("所以,调皮的怪物。这一次你想出的学习时间是");
			cin >> hour;
		}
		system("cls");
	}
	//没啥用的东西
	printf("-------------------------------------------------\n");
	printf("你确定这个学习时间是你的真实写照吗?\n");
	printf("\n");
	printf("    1.是     2.否\n");
	printf("-------------------------------------------------\n");
	printf("你的回答是:");
	int n;
	cin >> n;
	system("cls");
	if (n != 1 && n != 2)
	{
		printf("喂!你的输入违法啦!\n");
		system("pause");
		printf("\n");
		printf("故意的!?\n");
		system("pause");
		printf("\n");
		printf("不小心的!?\n");
		system("pause");
		printf("\n");
		printf("但不管怎么样,我为你准备的对话也到此为止了。\n");
		printf("\n");
		printf("接下来,直接进入摸鱼时间!\n");
		system("pause");
		printf("\n");
		system("cls");
	}
	if (n == 1)
	{
		printf("真的?\n");
		system("pause");
		printf("\n");
		printf("哈哈,逗你玩的。\n");
		printf("游戏而已,别紧张。身为你的游戏程序,我是百分百相信主人的。\n");
		system("pause");
		printf("\n");
		printf("什么!?你不紧张。\n");
		printf("好吧,我知道了。\n");
		printf("注意:小程序正在一旁默默地叹气并沉浸在失落中。\n");
		system("pause");
		printf("\n");
		printf("PS:嗨~~~这届的玩家真难带。\n");
		system("pause");
	}
	if (n == 2)
	{
		printf("真诚实呢!\n");
		printf("可惜啊!就算是诚实的怪物,在这个黑心企业的游戏中也没糖果吃吧!\n");
		system("pause");
		printf("\n");
		printf("注意:所以的骚操作都是出门忘带脑的策划想的,正所谓冤有头......\n");
		system("pause");
		printf("\n");
		printf("PS:要福利可以找策划,因为它没带脑,所以基本上什么都会答应。大概\n");
		system("pause");
	}
	system("cls");
	//学霸的上课和摸鱼
	if (job == 1)
	{
		IQ = IQ + (0.1*hour);
		printf("/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/\n");
		printf("\n");
		printf("在享受了轻松且愉快的%d个小时的学习时间后,您的智力一如既往地增加了%g!\n", hour, (0.1*hour));
		printf("\n");
		if (hour != 6)
		{
			printf("那么接下来,就是枯燥而无聊的摸鱼时间了!\n");
			printf("\n");
		}
		printf("/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/\n");
		printf("\n");
		system("pause");
		system("cls");
		//学霸的随机事件
		srand((unsigned int)time(0));//随机数
		int i = rand() % 3;//产生0到3之间的随机数
		if (i == 0)
		{
			printf("------------------------------------------------------------\n");
			printf("\n");
			printf("真遗憾,摸鱼时间内并没有发生任何突发事件。\n");
			printf("\n");
			printf("------------------------------------------------------------\n");
		}
		//压力+5
		if (i == 1)
		{
			pressure = pressure + 5;
			printf("----------------------------------------------------------------------\n");
			printf("\n");
			printf("百般无聊之际,你在老师温柔地注视下,以及周围同学嫉妒的眼神中,\n");
			printf("\n");
			printf("睡着了\n");
			printf("\n");
			printf("突然,你的睡梦中出现了一道身影,那是一道无比熟悉的身影\n");
			printf("\n");
			printf("那道身影的主人是无比强大,甚至连你也自愧不如的存在\n");
			printf("\n");
			printf("这时,那道早已离开学校的身影却似乎在微笑地告诉你:我要回来啦!\n");
			printf("\n");
			printf("顷刻间,你猛地从梦中惊醒,惊恐地看着周围诧异的同学和老师。\n");
			printf("\n");
			printf("那一天,本已俯视众生的学霸终于回想起了\n");
			printf("\n");
			printf("在实力至上的校园中被学神所支配的恐惧。\n");
			printf("\n");
			printf("----------------------------------------------------------------------\n");
			printf("PS:于是,惊恐的学霸压力值增加了5\n");
		}
		//压力-5
		if (i == 2)
		{
			pressure = pressure - 5;
			printf("---------------------------------------------------------------------\n");
			printf("\n");
			printf("看着布满简单纹路的黑板,你不由地闭上了眼,陷入沉思\n");
			printf("\n");
			printf("因无敌而寂寞的你渴望着与强者交流探讨\n");
			printf("\n");
			printf("这时,你的思绪开始变得恍惚。\n");
			printf("\n");
			printf("顷刻间,你仿佛梦见了许多位伟人,他们都充满期待地看向你\n");
			printf("\n");
			printf("你没有犹豫,与他们畅谈世间万物\n");
			printf("\n");
			printf("看着眼前的伟人们,与他们共享此刻的天伦之乐\n");
			printf("\n");
			printf("你不禁放声大笑,尽管是在原本鸦雀无声的教室之中,在老师和同学们的懵逼和惊愕之中\n");
			printf("\n");
			printf("---------------------------------------------------------------------\n");
			printf("PS:最后,脸红的学霸压力值减少了5\n");
		}
		printf("\n");
		system("pause");
		system("cls");
	}
	//体育生的上课和摸鱼
	if (job == 2)
	{
		IQ = IQ + (0.05*hour);
		printf("/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/\n");
		printf("\n");
		printf("在经历了漫长且痛苦的%d个小时的折磨后,您的智力惊喜地增加了%g!\n", hour, (0.05*hour));
		printf("\n");
		if (hour != 6)
		{
			printf("那么接下来,就是舒适而开心的摸鱼时间了!\n");
			printf("\n");
		}
		printf("/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/\n");
		system("pause");
		system("cls");
		//体育生的随机事件
		srand((unsigned int)time(0));//随机数
		int i = rand() % 3;//产生0到3之间的随机数
		if (i == 0)
		{
			printf("-------------------------------------------------\n");
			printf("\n");
			printf("真遗憾,摸鱼时间内并没有发生任何突发事件。\n");
			printf("\n");
			printf("-------------------------------------------------\n");
		}
		//压力+5
		if (i == 1)
		{
			pressure = pressure + 5;
			printf("------------------------------------------------------------------------------\n");
			printf("\n");
			printf("不经意间,你看向了窗外的篮球场,有人正在那挥舞着身躯,拍打着篮球\n");
			printf("\n");
			printf("而那同样是你挥洒汗水,克敌制胜的舞台\n");
			printf("\n");
			printf("你喜欢体育竞技带来的热血、青春活力和紧张的刺激感\n");
			printf("\n");
			printf("突然,你看到了那朝思暮想的身影,是那个你无比在意的她\n");
			printf("\n");
			printf("她的笑容很甜,那迷人的双眼更加凸显了她此刻洋溢着幸福的笑意\n");
			printf("\n");
			printf("青涩的你想知道究竟是什么事物才能让她如花儿一般绽放出如此灿烂的笑容\n");
			printf("\n");
			printf("于是,你顺着她那视线望去\n");
			printf("\n");
			printf("顷刻间,你愣住了\n");
			printf("\n");
			printf("那是一个在篮球场上,并不时以柔情似水的眼神回望她的身影\n");
			printf("\n");
			printf("也是一个把你推入万丈深渊,让你此刻痛不欲生的存在\n");
			printf("\n");
			printf("------------------------------------------------------------------------------\n");
			printf("PS:最后,想哭爹喊娘的体育生压力值增加了5\n");
		}
		//压力-5
		if (i == 2)
		{
			pressure = pressure - 5;
			printf("---------------------------------------------------------------------------\n");
			printf("\n");
			printf("发呆之余,你想起了篮球史上的传奇科比·布莱恩特去世的新闻\n");
			printf("\n");
			printf("你不禁悲伤起来,作为儿时的偶像,他一直是你不断前进的动力\n");
			printf("\n");
			printf("现在,你渴望与他同台打球的梦想已经悄然破灭\n");
			printf("\n");
			printf("就算成为了与他媲美的存在,也没有被他在台下欢呼喝彩、起身鼓掌的机会了\n");
			printf("\n");
			printf("缓过神来以后,你下意识的看了看周围的队友\n");
			printf("\n");
			printf("回想着与队友同甘共苦的种种训练\n");
			printf("\n");
			printf("失去初心,回到原点\n");
			printf("\n");
			printf("那唯一能做的就只有再一次出发、前进\n");
			printf("\n");
			printf("你在时,我们就已然在追寻你的背影\n");
			printf("\n");
			printf("你不在时,我们仍旧会追寻你的背影\n");
			printf("\n");
			printf("我们仍会继续追赶你的征途,只不过这一次\n");
			printf("\n");
			printf("你不在山顶,而是在更高的群星之上\n");
			printf("\n");
			printf("我们终将会相遇\n");
			printf("\n");
			printf("---------------------------------------------------------------------------\n");
			printf("PS:最后,怀着满腔热血却被自己感动的要哭的体育生压力值减少了5\n");
		}
		system("pause");
		system("cls");
	}
	//网瘾少年的上课和摸鱼
	if (job == 3)
	{
		IQ = IQ + (0.08*hour);
		printf("/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/\n");
		printf("\n");
		printf("浑水摸鱼了非人言且意义不明的%d个小时的神圣洗礼后,您的智力有如神助般地增加了%g!\n", hour, (0.08*hour));
		printf("\n");
		if (hour != 6)
		{
			printf("那么接下来,就是热血奋战的摸鱼时间了!\n");
			printf("\n");
		}
		printf("/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/\n");
		system("pause");
		system("cls");
		//网瘾少年的随机事件
		srand((unsigned int)time(0));//随机数
		int i = rand() % 3;//产生0到3之间的随机数
		if (i == 0)
		{
			printf("------------------------------------------------------------\n");
			printf("\n");
			printf("真遗憾,摸鱼时间内并没有发生任何突发事件。\n");
			printf("\n");
			printf("------------------------------------------------------------\n");
		}
		//压力+5
		if (i == 1)
		{
			pressure = pressure + 5;
			printf("------------------------------------------------------------------------------\n");
			printf("\n");
			printf("在久违的自习课上,你习以为常地拿出手机\n");
			printf("\n");
			printf("打开了那美妙又令人癫狂的游戏\n");
			printf("\n");
			printf("比起无聊的现实世界,你更喜欢沉浸在丰富多彩、惊喜不断的虚拟世界\n");
			printf("\n");
			printf("但与其说是更喜欢虚拟世界,倒不如说是对现实世界没多少感觉\n");
			printf("\n");
			printf("突然,游戏中弹出了未成年人防沉迷的窗口\n");
			printf("\n");
			printf("你不禁诧异,这比以前要来的更早\n");
			printf("\n");
			printf("于是,你搜索了相关信息\n");
			printf("\n");
			printf("发现未成年人防沉迷系统升级了,玩游戏的时间变的更加有限了\n");
			printf("\n");
			printf("也就是说,以后玩游戏要更加争分夺秒、如饥似渴、狼吞虎咽\n");
			printf("\n");
			printf("顷刻间,你意识到了自己在未来的生物进化路线\n");
			printf("\n");
			printf("那就是除了头以外,身上全是肝\n");
			printf("\n");
			printf("------------------------------------------------------------------------------\n");
			printf("PS:无语的网瘾少年压力值增加5\n");
		}
		//压力-5
		if (i == 2)
		{
			pressure = pressure - 5;
			printf("---------------------------------------------------------------------------------------------------\n");
			printf("\n");
			printf("在罕见的体育课上,自由活动一开始\n");
			printf("\n");
			printf("你就马上找了给隐秘的地方藏了起来\n");
			printf("\n");
			printf("闲来无事,你抽了一发,金色传说!\n");
			printf("\n");
			printf("你不禁暗叹:呵,有点意思\n");
			printf("\n");
			printf("于是,你怀着侥幸而忐忑的心,点了数发十连\n");
			printf("\n");
			printf("奇迹啊!都是十连十金!\n");
			printf("\n");
			printf("你马上打了自己一巴掌,疼\n");
			printf("\n");
			printf("你瞪大眼睛,然后返祖现象般地欢呼雀跃\n");
			printf("\n");
			printf("尽管你仍旧在怀疑这个剧本是错的,或者是编剧没动脑乱写的\n");
			printf("\n");
			printf("这时,刚好路过的班主任却闻声而来\n");
			printf("\n");
			printf("顷刻间,像猿猴一样举起双手的你愣在那,并注视着怒气冲天却又像见了鬼一样的班主任\n");
			printf("\n");
			printf("之后,你趁班主任还没反应过来,双手恭维地奉上了手机\n");
			printf("\n");
			printf("并熟练地走在了和班主任喝茶的路上\n");
			printf("\n");
			printf("在路上,你暗想到:以普遍理性而言,一部手机换今天的运气,我确实是赚了\n");
			printf("\n");
			printf("况且我从来都不是只有一把圣剑的人\n");
			printf("\n");
			printf("---------------------------------------------------------------------------------------------------\n");
			printf("PS:欣喜若狂的网瘾少年压力值-5\n");
		}
		system("pause");
		system("cls");
	}
}

以下是主程序

#include <iostream>
#include <Windows.h> 
#include <stdlib.h>
#include <fstream>
#include <cstdlib>
#include "Activity.h"

using namespace std;

void slip(int num)
{
	int j = num / 10;
	for (int i = 0; i < j; i++)
	{
		cout << "■";
	}
}

void personstate(Activity&guy)//状态栏
{
	system("color F5");
	cout << "- - - - - - - - - - - - - - 人物状态 - - - - - - - - - - - - - -" << endl;
	cout << "- 智力       ";
	slip(guy.IQ);
	cout << " " << guy.IQ;
	cout << endl;
	cout << "- 体魄       ";
	slip(guy.build);
	cout << " " << guy.build;
	cout << endl;
	cout << "- 压力值     ";
	slip(guy.pressure);
	cout << " " << guy.pressure;
	cout << endl;
	cout << "- 父母满意度 ";
	slip(guy.satisfaction);
	cout << " " << guy.satisfaction;
	cout << endl;
	cout << "- 已有金钱 " << guy.money << "      " << "时间 " << guy.times << "      " << "已进行天数 " << guy.day << " /" << guy.playday << endl;
	cout << "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - " << endl;

}
/*
cout << "- - - - - - - - - - - - - - 人物状态 - - - - - - - - - - - - - -" << endl;
cout << "- 智力 " << guy.IQ << "                            已有金钱 " << guy.money << endl;
cout << "- 体魄 " << guy.build << "                                时间 " << guy.times << endl;
cout << "- 压力值 " << guy.pressure << endl;
cout << "- 父母满意度 " << guy.satisfaction << "                      已进行天数 " << guy.day << " /" << guy.playday << endl;
cout << "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - " << endl;*/

void menu()//二级菜单
{
	system("color F1");
	cout << "************ 活动选择 ************" << endl;
	cout << "**           1.去网吧           **" << endl;
	cout << "**           2.去健身           **" << endl;
	cout << "**           3.去公园           **" << endl;
	cout << "**           4.回家里           **" << endl;
	cout << "**           5.去购物           **" << endl;
	cout << "**           6.保存并退出       **" << endl;
	cout << "**           7.查看地图         **" << endl;
	cout << "**********************************" << endl;
	cout << "你的选择是:";
}

void map()//地图
{
	{
		cout << "                     【学校】 【开发中###】                            \n";
		cout << "                        |      /                                \n";
		cout << "                        |    /                                \n";
		cout << "                        |  /                              \n";
		cout << "     【商场】— — —【家】— — —【网吧】                                      \n";
		cout << "                     /     \                             \n";
		cout << "                    /       \                                \n";
		cout << "                   /         \                               \n";
		cout << "           【公园】           【健身房】                              \n";
		cout << "                                                            \n";
	}
}

void count(Activity& guy)
{
	cout << "你的结局是:" << endl;
	cout << endl;
	cout << endl;
	double main;
	main = guy.IQ * 0.25 + guy.build * 0.25 + guy.satisfaction * 0.25 + (100 - guy.pressure) * 0.25;
	if (main >= 60)
	{
		double a;
		a = guy.IQ - guy.build;
		if (a >= 10)
		{
			cout << "经过你的不断努力!! \n 你的成绩非常突出!!\n 你被保送清华北大!!\n 你很有头脑 你的智商超群" << endl;//*
		}
		else if (a < 10 && a >= 0)
		{
			cout << "你的成绩很好!!\n 综合成绩很好!!\n 但你在学霸李没有什么亮点!!\n 你是一个低调学霸" << endl;//*

		}
		else if (a < -10)
		{
			cout << "学霸中的体育生!!尽管学习成绩在学霸群体里没那么突出!!\n但你有一个强健的体魄!! \n魅力四射!!!迷倒很多小学妹!!\n你成为了 super 学霸体育生" << endl;//*
		}
		else if (a > -10 && a < 0)
		{
			cout << "综合成绩优秀!!\n但你离真正的学霸体育生还有一段距离!!\n离迷倒无数小学妹 还有一段路要走!!\n但你的体魄相较于常人有一定的优势!!\n你成为了未来中的 学霸体育生.ing!!" << endl;//*
		}
		else if (guy.pressure <= 20)
		{
			cout << "你不仅综合成绩优秀!!\n 还很能放松自己!!\n很会享受学习的过程!!很会调节自己!!\n是品学玩兼优的学霸思想家!!" << endl;//*
		}
	}
	else if (main < 60 && main >= 50)
	{
		double a;
		a = guy.IQ - guy.build;
		if (a >= 10)
		{
			cout << "你综合成绩平常!!\n是个工薪阶级!!也是有脑子的工薪阶层!!\n但并不能说你很优秀!!\n你还有待提升成为你想成为的人!!你的体魄是你值得注意的!!\n你成为了 奋斗中的!有脑子的!工薪阶级!!" << endl;//*
		}
		else if (a < 10 && a >= 0)
		{
			cout << "对于你! 我只能说你很普通!!\n没什么长处!!\n你的各方面都有待提升!!\n普通!平凡!是你的代名词!!\n你成为了平凡普通的工薪阶层!!" << endl;//*

		}
		else if (a < 0 && a>-10)
		{
			cout << "成绩普通!!\n肌肉略微发达!!\n奥!对也不能说发达!!\n只能说是略微发达!!!\n你的学习能力还有待提升!!\n你成为了 身上挂了点肌肉的!工薪阶层!!" << endl;//*
		}
		else if (a <= -10)
		{
			cout << "肌肉男你好!!\n尽管你成绩普通!!\n但强健的体魄成为了你的一大亮点!!\n你成为了 工薪阶层.肌肉男.ing" << endl;//*
		}
	}
	else if (main < 50)
	{
		cout << "对于你!!\n我竟无言以对!!你明明可以不断努力!!\n借此来提升自己的各个方面!!\n但是你的选择却让你生活困难 无法自理 终日以“口水泡馍”充饥!!\n你成为了社会最底层的贫民!!" << endl;//*
	}
	cout << endl;
	cout << endl;
	cout << "* * * * * * * * * * * * * * * * * * * * * * * * " << endl;
	cout << "你是否同意这一结果???   还有机会翻身哦!! *" << endl;
	cout << "1.同意  2.不同意 3.我无所谓!!               *" << endl;
	cout << "* * * * * * * * * * * * * * * * * * * * * * * * " << endl;
	cout << endl;
	int b;
	cout << "请输入:";
	cin >> b;
	while (b != 1 && b != 2 && b != 3)
	{
		cout << "输入违法!\n请重新输入:";
		cin >> b;
	}
	if (b == 1)
	{
		cout << "看来你对你的结果十分满意!!\n你也对你的努力很认可!!\n尽管你不是最好的那一个!!\n生活是很美好的!!\n你的态度很重要!!" << endl;
	}
	else if (b == 2)
	{
		cout << "看来你对现状很是不满意!! \n你的结局是由你自己来改变的!!\n想翻身??impossible!!\n咸鱼翻身还是咸鱼!!\n当然了!这次只是一个前车之鉴!!\n你可以再来一次!!来逆天改命!! " << endl;
	}
	else if (b == 3)
	{
		cout << "看来是个老油条了!!\n你注定一事无成!!\n" << endl;
	}

}



void menu1() {
	system("color F0");
	system("mode 200,80");
	cout << "                       ,`          ,]`                                 ,]]`                                                                        *]]]`                    \n";
	cout << "            ,@@`      ,@@@\         @@@^                                @@@@  ,@@]                          =@@@^                          ]]       *@@@^                   \n";
	cout << "            ,@@@@\*    *@@@@*      =@@@*                                @@@@  ,@@@@@`                       =@@@^                         =@@@^     *@@@^                   \n";
	cout << "              ,@@@@^     \@/`     *@@@\]]]]]]]]]]` =@@@@@@@@@@@@@@^     =@@@    *\@@@@^                     @@@@                         =@@@/      *@@@^                   \n";
	cout << "                ,[=@@@@@@@@@@@@@@*@@@@@@@@@@@@@@@^ ,[[[[[[[[[[\@@@`     =@@@       ,@*                     *@@@@                        =@@@@]]]]]]]]@@@\]]]]]]]]]]]]]]*    \n";
	cout << "                  ,@@@@@@@@@@@@@@@@@/                         =@@@      =@@@     *]]]]@@@                  =@@@@                       =@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@^    \n";
	cout << "          *@@@`      *@@@*     ,@@@@]]]]]]]]]]]]*  ,/@@`      @@@^,]]@@@@@@@@@@@@@@@@@@@@                  @@@@@^                     /@@@/         *@@@^                   \n";
	cout << "          *\@@@@\*   *@@@*     ,@@/@@@@@@@@@@@@@^   ,@@@\    =@@@`=@@@@@@@@@/[[*                          =@@@@@@`                  ,@@@@^          *@@@^                   \n";
	cout << "             ,@@@@`  =@@@]]]]]]]`          /@@@/*    *@@@@`  @@@@       *@@@^      ,\`                   *@@@@\@@@                 /@@@@`           *@@@^                   \n";
	cout << "               ,[    =@@@@@@@@@@^        ,@@@/*        \@@@^=@@@`        @@@^     ,@@@/                  /@@@^*@@@\               *\@@/             *@@@^                   \n";
	cout << "                     =@@@    @@@*      *@@@/*           ,@@@@@@^         =@@@    /@@@/                  =@@@/  ,@@@\                ,* ,]]]]]]]]]]]]]@@@\]]]]]]]]]]]]]*     \n";
	cout << "               ]*    =@@@   *@@@,]]]]]]]@@@]]]]]]]       *@@@@@          =@@@* *@@@@`                  =@@@@    =@@@\                  @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@^     \n";
	cout << "              =@@@^  =@@/   ,@@@=@@@@@@@@@@@@@@@@@        @@@@@^          @@@^=@@@@*                  /@@@@*     =@@@@*                             *@@@^                   \n";
	cout << "              /@@@   @@@^   =@@@       *@@@             *@@@@@@@\         =@@@@@@`                  *@@@@/        ,@@@@`                            *@@@^                   \n";
	cout << "             ,@@@^  =@@@*   =@@@       *@@@            ,@@@@*,@@@@*       ,@@@@/      /@]`         /@@@@^          *@@@@@`                          *@@@^                   \n";
	cout << "             /@@@   @@@^    =@@@       *@@@           /@@@/   ,@@@@`    ,@@@@@@^      @@@/       ,@@@@@`             \@@@@@`                        *@@@^                   \n";
	cout << "            ,@@@^  =@@@*    =@@/       *@@@         ,@@@@^     *@@/` */@@@@/,@@@\    =@@@^    */@@@@@`                *\@@@@@]*                     *@@@^                   \n";
	cout << "            /@@@* /@@@`*   ,@@@^       =@@@       ,@@@@/*         */@@@@@[   ,@@@@\  /@@@   ,@@@@@@`                    ,\@@@@@@\`=@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@  \n";
	cout << "          =@@@^*@@@@` @@@@@@@/   @@@@@@@@/        \@@`          ,@@@@/*       =@@@@@@@@` *\@@@@@`                         \@@@@/ =@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@/   \n";
	cout << "            ,[@* *\/*             ,[[[[[`                          ,*            ,\@@@/*    ,@`                              *[*                                            \n";
	cout << endl;
	cout << endl;
	cout << endl;
	cout << "                                                              游戏载入中 [";

	for (int i = 0; i <= 100; i++)      // 打印百分比 
	{
		if (i % 2 == 0)
			cout << "#";
		if (i == 100)
			cout << "]";
		cout.width(3);//i的输出为3位宽
		cout << i << "%";
		Sleep(10);
		cout << "\b\b\b\b";//回删三个字符,使数字在原地变化
	}

}

void save(Activity&guy)//文件保存
{
	ofstream outFile;
	outFile.open("data.txt");//将对象与文件关联	
	outFile << guy.job << " " << guy.build << " " << guy.satisfaction << " " << guy.pressure << " " << guy.money << " " << guy.times << " " << guy.IQ << " " << guy.day << " " << guy.playday << " ";
	outFile.close();

}

Activity read(Activity& gay)
{
	ifstream inFile;
	inFile.open("data.txt");
	if (!inFile.is_open())//判断文件是否成功打开
	{
		cout << "文件没成功打开" << endl;
		exit(EXIT_FAILURE);
	}
	inFile >> gay.job >> gay.build >> gay.satisfaction >> gay.pressure >> gay.money >> gay.times >> gay.IQ >> gay.day >> gay.playday;
	inFile.close();
	return gay;
}

void information()
{
	cout << "\n\n";
	cout << "                                                                                      ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" << endl;
	cout << "                                                                                      ┃在这里,你将为你喜欢的角色做出各式各样的选择,触发各种突发事件,引导他们走向不同的结局  " << endl;
	cout << "                                                                                      ┃那么,准备好开始你在这里的游戏人生了吗?                                                " << endl;
	cout << "                                                                                      ┃                                                                                       " << endl;
	cout << "                                                                                      ┃ 创作者:马翔远 马汉卿 莫阔杰 潘子哲  祁耀东                                                   " << endl;
	cout << "                                                                                      ┃                                                                         " << endl;
	cout << "                                                                                      ┃ 版本:1.1.1											                                 " << endl;
	cout << "                                                                                      ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" << endl;
	system("pause");
	system("cls");
	system("mode 120,30");
}

int main() {
	Activity guy, guy1;
	int activity;
	menu1();
	information();
	//主游戏菜单
	system("color F3");
	int choice = 0, person = 0;
	cout << "========游戏菜单========" << endl;
	cout << "=   *1.创建学生         =" << endl;
	cout << "=   *2.读取存档         =" << endl;
	cout << "=   *3.退出             =" << endl;
	cout << "========================" << endl;
	system("color F0");

	cout << "您的选择是:";
	cin >> choice;
	while (choice != 1 && choice != 2 && choice != 3) 
	{
		cout << "您想实现的功能仍在完善,请重新输入:";//输入不合法要重新输入
		cin >> choice;
	}
	system("cls");
	if (choice == 1)
	{
		cout << "========人物选择========" << endl;
		cout << "=   *1.学霸            =" << endl;
		cout << "=   *2.体育生          =" << endl;
		cout << "=   *3.网瘾少年        =" << endl;
		cout << "========================" << endl;
		int choose;
		cout << "请输入你要选择的人物:";
		cin >> choose;

		while (choose != 1 && choose != 2 && choose != 3) 
		{
			cout << "没有你想创建的人物哦,请重新输入:";//输入不合法要重新输入
			cin >> choose;
		}
		Guy gay(choose);//生成人物对象
		Activity guy1(gay);
		guy = guy1;

		cout << "请输入想要养成的天数:";
		cin >> guy.playday;
		while (guy.playday <= 1)
		{
			cout << "你活的时间太短了,请重新输入:";
			cin >> guy.playday;
		}
	}
	else if (choice == 2) 
	{
		guy = read(guy1);//文件读取
	}
	else if (choice == 3) 
	{
		cout << "真的要残忍离开吗o(╥﹏╥)o";
	}
	//一级菜单

	system("cls");
	/*if (choice == 1) {
		personstate(guy);
	}*/
	while (guy.day <= guy.playday)
	{
		
		if (guy.day > 1 )
		{ 
			if(choice != 2)
			personstate(guy);
			choice = 3;
		}
		if (guy.times == 0)
		{
			cout << "一日之计在于晨,新的一天你将从学习开始" << endl;
			system("pause");
			guy.school();
		}
		while (1)
		{
			personstate(guy);
			menu();
			if (guy.pressure > 80)
			{
				cout << "你的压力太大啦!!!!!!请及时减压" << endl;
			}
			if (guy.satisfaction < 20)
			{
				cout << "父母对你很不满意!!!!!当心被逐出家门-----请及时提升父母满意度" << endl;
			}
			if (guy.build < 20)
			{
				cout << "身体是革命的本钱!!!!!多去健身健身吧!!!" << endl;
			}
			cin >> activity;
			while (activity < 1 || activity>7)
			{
				cout << "你想要的功能还在完善中,选择一个已经实现的吧" << endl;
				cin >> activity;
			}
			if (activity == 1)
			{
				system("cls");//清屏
				personstate(guy);
				guy.internetbar();//网吧

			}
			else if (activity == 2)
			{
				system("cls");//清屏
				personstate(guy);
				guy.gym();//健身

			}
			else if (activity == 3)
			{
				system("cls");//清屏
				personstate(guy);
				guy.park(); //公园

			}
			else if (activity == 4)
			{
				system("cls");//清屏
				personstate(guy);
				guy.home();//回家
				if (guy.times == 24)
				{
					guy.money = guy.money + guy.satisfaction*0.5;
					guy.build -= 1;
					guy.pressure += 2;
					guy.times = 0;
					system("cls");
					guy.day++;
					if (guy.day <= guy.playday)
					{
						cout << "第" << guy.day << "天开始了" << endl;
					}
					break;
				}
			}
			else if (activity == 5)
			{
				guy.shop();//商场

			}
			else if (activity == 6)
			{
				save(guy);//文件
				break;
			}
			else if (activity == 7)
			{
				map();
				system("pause");
			}
			
			system("cls");
			if (guy.day > guy.playday)
			{
				break;
			}
		}
		if (activity == 6 || guy.day > guy.playday)
		{
			break;
		}
	}
	if (guy.day > guy.playday)
	{
		cout << "恭喜你完成了一段短暂的人生" << endl;
		cout << "你的最终能力值为:" << endl;
		cout << "智商:" << guy.IQ << "      体魄:" << guy.build << endl;
		cout << "满意度:" << guy.satisfaction << "     压力:" << guy.pressure << endl;
		cout << endl;
		count(guy);
		cout << endl;
	}

}


思路应该挺简单的? ?但还是需要实践!!

  C++知识库 最新文章
【C++】友元、嵌套类、异常、RTTI、类型转换
通讯录的思路与实现(C语言)
C++PrimerPlus 第七章 函数-C++的编程模块(
Problem C: 算法9-9~9-12:平衡二叉树的基本
MSVC C++ UTF-8编程
C++进阶 多态原理
简单string类c++实现
我的年度总结
【C语言】以深厚地基筑伟岸高楼-基础篇(六
c语言常见错误合集
上一篇文章      下一篇文章      查看所有文章
加:2021-09-30 11:45:05  更:2021-09-30 11:46:23 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年5日历 -2024/5/19 20:50:46-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码