#include <ctime>
#include <cmath>
#include <cstdlib>
#include <cstring>
using namespace std;
/*三. 宠物类的实现:建立一个宠物类pet
1. 构造函数
2. 提取各个私有成员
3. 饥饿、口渴及心情随时间变化函数P2()
随机产生0~14之间的数m,若m<5,心情-2;若5<m<12,心情-1;其他 心情+1;
年龄+1;
饥饿度+1;
口渴度+1;
*/
#include <cstdlib>
#define MAX_N 110
int N, M;
char field[MAX_N][MAX_N];//创建园子
char a[2] = { '.', 'W' };
using namespace std;
void lvbu()
{
int xueliang = 100;
int nn = 100;
int t;
int xingdongdiren=35;
int xingdongzishen=35;
int counts = 1;
cout << "请开始输入您的技能" << endl;
cout <<"--------------------------------------------------------------" << endl;
while(cin >>t)
{
cout <<"第" << counts <<"回合" << endl;
cout <<"--------------------------------------------------------------" << endl;
switch(t)
{
case 1:
cout << "您使用的是技能宠物顶计" << endl;
cout <<"--------------------------------------------------------------" << endl;
break;
case 2:
cout << "您使用的技能是宠物快跑" << endl;
cout <<"--------------------------------------------------------------" << endl;
break;
case 3:
cout << "您使用的是技能萌系诱饵" << endl;
cout <<"--------------------------------------------------------------" << endl;
break;
case 4:
cout << "您使用的是技能免疫奶瓶" << endl;
cout <<"--------------------------------------------------------------" << endl;
break;
}
counts++;
switch(t)
{
case 1:
xueliang=xueliang-10;
xingdongzishen=xingdongzishen-2;
cout << "当前敌人的血量为" << xueliang << "当前你的行动值为" << xingdongzishen << endl;
cout <<"--------------------------------------------------------------" << endl;
break;
case 2:
xueliang=xueliang-20;
xingdongzishen=xingdongzishen-4;
cout << "当前敌人的血量为" << xueliang << "当前你的行动值为" << xingdongzishen << endl;
cout <<"--------------------------------------------------------------" << endl;
break;
case 3:
xueliang=xueliang-20;
xingdongzishen=xingdongzishen-5;
cout << "当前敌人的血量为" << xueliang << "当前你的行动值为" << xingdongzishen << endl;
cout <<"--------------------------------------------------------------" << endl;
break;
case 4:
xueliang=xueliang-30;
xingdongzishen=xingdongzishen-6;
cout << "当前敌人的血量为" << xueliang << "当前你的行动值为" << xingdongzishen << endl;
cout <<"--------------------------------------------------------------" << endl;
break;
}
cout << "敌人使用的技能为" ;
int a[4]= {1,2,3,4};
int bb =a[rand()%4];
cout << bb << endl;
switch(bb)
{
case 1:
cout << "敌人使用的技能为温侯连环斩" << endl;
cout <<"--------------------------------------------------------------" << endl;
nn=nn-15;
xingdongdiren=xingdongdiren-3;
cout << "宠物的血量为" << nn <<"敌人的行动值为"<< xingdongdiren << endl;
cout <<"--------------------------------------------------------------" << endl;
break;
case 2:
cout << "敌人使用的技能为十方横扫" << endl;
nn=nn-20;
xingdongdiren=xingdongdiren-5;
cout << "宠物的血量为" << nn <<"敌人的行动值为"<< xingdongdiren << endl;
cout <<"--------------------------------------------------------------" << endl;
break;
case 3:
cout << "敌人使用的技能为刚愎" << endl;
cout <<"--------------------------------------------------------------" << endl;
nn=nn-5;
xingdongdiren--;
cout << "宠物的血量为" << nn <<"敌人的行动值为"<< xingdongdiren << endl;
cout <<"--------------------------------------------------------------" << endl;
break;
case 4:
cout <<"敌人使用的技能为无双!" << endl;
cout <<"--------------------------------------------------------------" << endl;
nn=nn-20;
xingdongdiren=xingdongdiren-3;
cout << "宠物的血量为" << nn <<"敌人的行动值为"<< xingdongdiren << endl;
cout <<"--------------------------------------------------------------" << endl;
break;
}
cout << "请您继续选择技能" << endl;
if(xingdongdiren==0 || xueliang==0 || xingdongdiren<0 || xueliang <0)
{
cout <<"恭喜您击败了敌人" << endl;
cout <<"--------------------------------------------------------------" << endl;
break;
}
if(xingdongzishen==0 || nn==0 || xingdongzishen<0 || nn<0)
{
cout <<"很遗憾您失败了" << endl;
cout <<"--------------------------------------------------------------" << endl;
break;
}
}
}
void xiangyu()
{
int xueliang = 100;
int nn = 100;
int t;
int xingdongdiren=35;
int xingdongzishen=35;
int counts = 1;
cout << "请开始输入您的技能" << endl;
cout <<"--------------------------------------------------------------" << endl;
while(cin >>t)
{
cout <<"第" << counts <<"回合" << endl;
cout <<"--------------------------------------------------------------" << endl;
switch(t)
{
case 1:
cout << "您使用的是技能宠物顶计" << endl;
cout <<"--------------------------------------------------------------" << endl;
break;
case 2:
cout << "您使用的技能是宠物快跑" << endl;
cout <<"--------------------------------------------------------------" << endl;
break;
case 3:
cout << "您使用的是技能萌系诱饵" << endl;
cout <<"--------------------------------------------------------------" << endl;
break;
case 4:
cout << "您使用的是技能免疫奶瓶" << endl;
cout <<"--------------------------------------------------------------" << endl;
break;
}
counts++;
switch(t)
{
case 1:
xueliang=xueliang-10;
xingdongzishen=xingdongzishen-2;
cout << "当前敌人的血量为" << xueliang << "当前你的行动值为" << xingdongzishen << endl;
cout <<"--------------------------------------------------------------" << endl;
break;
case 2:
xueliang=xueliang-20;
xingdongzishen=xingdongzishen-4;
cout << "当前敌人的血量为" << xueliang << "当前你的行动值为" << xingdongzishen << endl;
cout <<"--------------------------------------------------------------" << endl;
break;
case 3:
xueliang=xueliang-20;
xingdongzishen=xingdongzishen-5;
cout << "当前敌人的血量为" << xueliang << "当前你的行动值为" << xingdongzishen << endl;
cout <<"--------------------------------------------------------------" << endl;
break;
case 4:
xueliang=xueliang-30;
xingdongzishen=xingdongzishen-6;
cout << "当前敌人的血量为" << xueliang << "当前你的行动值为" << xingdongzishen << endl;
cout <<"--------------------------------------------------------------" << endl;
break;
}
cout << "敌人使用的技能为" ;
int a[4]= {1,2,3,4};
int bb =a[rand()%4];
cout << bb << endl;
switch(bb)
{
case 1:
cout << "敌人使用的技能为剑刃风暴" << endl;
cout <<"--------------------------------------------------------------" << endl;
nn=nn-15;
xingdongdiren=xingdongdiren-3;
cout << "宠物的血量为" << nn <<"敌人的行动值为"<< xingdongdiren << endl;
cout <<"--------------------------------------------------------------" << endl;
break;
case 2:
cout << "敌人使用的技能为剑气" << endl;
nn=nn-20;
xingdongdiren=xingdongdiren-5;
cout << "宠物的血量为" << nn <<"敌人的行动值为"<< xingdongdiren << endl;
cout <<"--------------------------------------------------------------" << endl;
break;
case 3:
cout << "敌人使用的技能为剑舞" << endl;
cout <<"--------------------------------------------------------------" << endl;
nn=nn-5;
xingdongdiren--;
cout << "宠物的血量为" << nn <<"敌人的行动值为"<< xingdongdiren << endl;
cout <<"--------------------------------------------------------------" << endl;
break;
case 4:
cout <<"敌人使用的技能为鬼雄!" << endl;
cout <<"--------------------------------------------------------------" << endl;
nn=nn-20;
xingdongdiren=xingdongdiren-3;
cout << "宠物的血量为" << nn <<"敌人的行动值为"<< xingdongdiren << endl;
cout <<"--------------------------------------------------------------" << endl;
break;
}
cout << "请您继续选择技能" << endl;
if(xingdongdiren==0 || xueliang==0 || xingdongdiren<0 || xueliang <0)
{
cout <<"恭喜您击败了敌人" << endl;
cout <<"--------------------------------------------------------------" << endl;
break;
}
if(xingdongzishen==0 || nn==0 || xingdongzishen<0 || nn<0)
{
cout <<"很遗憾您失败了" << endl;
cout <<"--------------------------------------------------------------" << endl;
break;
}
}
}
void ximenfeixue()
{
int xueliang = 100;
int nn = 100;
int t;
int xingdongdiren=35;
int xingdongzishen=35;
int counts = 1;
cout << "请开始输入您的技能" << endl;
cout <<"--------------------------------------------------------------" << endl;
while(cin >>t)
{
cout <<"第" << counts <<"回合" << endl;
cout <<"--------------------------------------------------------------" << endl;
switch(t)
{
case 1:
cout << "您使用的是技能宠物顶计" << endl;
cout <<"--------------------------------------------------------------" << endl;
break;
case 2:
cout << "您使用的技能是宠物快跑" << endl;
cout <<"--------------------------------------------------------------" << endl;
break;
case 3:
cout << "您使用的是技能萌系诱饵" << endl;
cout <<"--------------------------------------------------------------" << endl;
break;
case 4:
cout << "您使用的是技能免疫奶瓶" << endl;
cout <<"--------------------------------------------------------------" << endl;
break;
}
counts++;
switch(t)
{
case 1:
xueliang=xueliang-10;
xingdongzishen=xingdongzishen-2;
cout << "当前敌人的血量为" << xueliang << "当前你的行动值为" << xingdongzishen << endl;
cout <<"--------------------------------------------------------------" << endl;
break;
case 2:
xueliang=xueliang-20;
xingdongzishen=xingdongzishen-4;
cout << "当前敌人的血量为" << xueliang << "当前你的行动值为" << xingdongzishen << endl;
cout <<"--------------------------------------------------------------" << endl;
break;
case 3:
xueliang=xueliang-20;
xingdongzishen=xingdongzishen-5;
cout << "当前敌人的血量为" << xueliang << "当前你的行动值为" << xingdongzishen << endl;
cout <<"--------------------------------------------------------------" << endl;
break;
case 4:
xueliang=xueliang-30;
xingdongzishen=xingdongzishen-6;
cout << "当前敌人的血量为" << xueliang << "当前你的行动值为" << xingdongzishen << endl;
cout <<"--------------------------------------------------------------" << endl;
break;
}
cout << "敌人使用的技能为" ;
int a[4]= {1,2,3,4};
int bb =a[rand()%4];
cout << bb << endl;
switch(bb)
{
case 1:
cout << "敌人使用的技能为落花吹雪" << endl;
cout <<"--------------------------------------------------------------" << endl;
nn=nn-15;
xingdongdiren=xingdongdiren-3;
cout << "宠物的血量为" << nn <<"敌人的行动值为"<< xingdongdiren << endl;
cout <<"--------------------------------------------------------------" << endl;
break;
case 2:
cout << "敌人使用的技能为追风剑" << endl;
nn=nn-20;
xingdongdiren=xingdongdiren-5;
cout << "宠物的血量为" << nn <<"敌人的行动值为"<< xingdongdiren << endl;
cout <<"--------------------------------------------------------------" << endl;
break;
case 3:
cout << "敌人使用的技能为追魂剑" << endl;
cout <<"--------------------------------------------------------------" << endl;
nn=nn-5;
xingdongdiren--;
cout << "宠物的血量为" << nn <<"敌人的行动值为"<< xingdongdiren << endl;
cout <<"--------------------------------------------------------------" << endl;
break;
case 4:
cout <<"敌人使用的技能为天外飞仙!" << endl;
cout <<"--------------------------------------------------------------" << endl;
nn=nn-20;
xingdongdiren=xingdongdiren-3;
cout << "宠物的血量为" << nn <<"敌人的行动值为"<< xingdongdiren << endl;
cout <<"--------------------------------------------------------------" << endl;
break;
}
cout << "请您继续选择技能" << endl;
if(xingdongdiren==0 || xueliang==0 || xingdongdiren<0 || xueliang <0)
{
cout <<"恭喜您击败了敌人" << endl;
cout <<"--------------------------------------------------------------" << endl;
break;
}
if(xingdongzishen==0 || nn==0 || xingdongzishen<0 || nn<0)
{
cout <<"很遗憾您失败了" << endl;
cout <<"--------------------------------------------------------------" << endl;
break;
}
}
}
void dfs(int x, int y)
{
field[x][y] = '.';//把现在的位置改为.
//循环遍历移动的八个方向
for (int dx = -1; dx <= 1; dx++)
{
for (int dy = -1; dy <= 1; dy++)
{
//向x方向移动dx,向y方向移动dy,移动的结果为(nx,ny)
int nx = x + dx;
int ny = y + dy;
//判断(nx,ny)是不是在园子里面,以及是否有积水。
if (0 <= nx && nx<N && 0 <= ny && ny<M && field[nx][ny] == 'W')
{
dfs(nx, ny);
}
}
}
}
int tim(char a)
{
int times = 0;
switch (a)
{
case 'a':
case 'd':
case 'g':
case 'j':
case 'm':
case 'p':
case 't':
case 'w':
case ' ':
times = 1;
break;
case 'b':
case 'e':
case 'h':
case 'k':
case 'n':
case 'q':
case 'u':
case 'x':
times = 2;
break;
case 'c':
case 'f':
case 'i':
case 'l':
case 'o':
case 'r':
case 'v':
case 'y':
times = 3;
break;
case 's':
case 'z':
times = 4;
break;
}
return times;
}
class pet
{
int age, hunger, thirsty, mood, health, hp, mdp, movepoint;
public:
pet(int a = 0, int b = 0, int c = 0, int d = 50, int e = 50, int z = 50)
{
age = a;//年龄
hunger = b;//饥饿度
thirsty = c;//口渴度
mood = d;//心情
health = e;//健康度
//hp = x;//
//mdp = y;
movepoint = z;//行动点数
}
int getage()
{
return age;
}
int gethunger()
{
return hunger;
}
int getthirsty()
{
return thirsty;
}
int getmood()
{
return mood;
}
int gethealth()
{
return health;
}
//int gethp(){
// return hp;
//}
/*int getmdp(){
return mdp;
}*/
int getmovepoint()
{
return movepoint;
}//提取各个属性
/* 饥饿、口渴及心情随时间变化函数P2()
随机产生0~14之间的数m,若m<5,心情-2;若5<m<12,心情-1;其他 心情+1;
年龄+1;
饥饿度+1;
口渴度+1;*/
void p2() //随时间变化
{
int m;
m = rand() % 15;
if (m<5) mood = mood - 2;
if (5<m && m <12) mood--;
else mood++;
age++;
hunger++;
thirsty++;
//cout << "现在的年龄是" << age << endl;
//cout <<"现在的心情是" << endl;
//cout << "现在的饥饿度是" << endl;
//cout << "现在的口渴度为" << endl;
}
/*4. 各个数值输出函数show():各个数值的输出函数
显示出现在的状态,如年龄,饥饿度,口渴度,心情指数,健康指数;*/
void show() //各数值输出函数
{
cout << "当前的状况是" << endl;
cout << "年龄:" << age;
cout << "心情" << mood;
cout << "饥饿" << hunger;
cout << "口渴度" << thirsty;
cout << "健康指数" << health << endl;
}
//特殊状况函数
/*5. 各个特殊状态函数emergency(emg)
特殊状态(随机值emg)
行动点数+5;
emg等于20(表示生病了),健康-1;
饥饿值=3 心情-1(饿了);
饥饿值=-2,心情-1(很饱了);
饥饿值>3,心情-1,(要饿死了);
饥饿值<-2,心情-2,健康-1(要撑死了);
口渴值=2,心情-1(好渴);
口渴值=-2,心情-1(喝够了);
口渴值>2,心情-2,健康-1(渴的受不了);
口渴值<-2,心情-2,健康-1,(喝撑了);
饥饿值>6或者口渴值>5,年龄=100,宠物死亡(万恶的主人);
饥饿值>5并且口渴值>4,年龄=100,宠物死亡(来世不跟你混了);
健康<-6,年龄=100,宠物死亡(倒下了)*/
void emergency(int emg)
{
movepoint = movepoint + 5;
if (emg == 20)
{
health--;
cout << "主人,人家好难受,生病了呀。" << endl;
}
if (hunger == 3)
{
mood--;
cout << "主银,人家好饿呀" << endl;
}
if (hunger == -2)
{
mood--;
cout << "主银,你把人家问的很饱了" << endl;
}
if (hunger > 3)
{
mood--;
cout << "主银!!!还不喂喂人家,人家都快饿死了" << endl;
}
if (hunger <-2)
{
mood = mood - 2;
health--;
cout << "主银,人家胃好难受啊!" << endl;
}
/*口渴值=2,心情-1(好渴);
口渴值=-2,心情-1(喝够了);
口渴值>2,心情-2,健康-1(渴的受不了);
口渴值<-2,心情-2,健康-1,(喝撑了);*/
if (thirsty == 2)
{
mood--;
cout << "主银,我好渴啊" << endl;
}
if (thirsty == -2)
{
cout << "主银,我喝够了" << endl;
}
if (thirsty > 2)
{
mood = mood - 2;
health--;
cout << "主银,人家已经很渴了" << endl;
}
if (thirsty < -2)
{
mood = mood - 2;
health--;
cout << "主银,人家已经喝撑了,不能再喝了。" << endl;
}
/*饥饿值>6或者口渴值>5,年龄=100,宠物死亡(万恶的主人);
饥饿值>5并且口渴值>4,年龄=100,宠物死亡(来世不跟你混了);
健康<-6,年龄=100,宠物死亡(倒下了)*/
if (hunger > 6 || thirsty > 5)
{
age = 100;
cout << "他走了,走的很惨,临走之前还不忘说,****,你这个万恶的主人" << endl;
}
if (hunger > 5 && thirsty > 4)
{
age = 100;
cout << "如果有来世,我一定不会跟着你了" << endl;
}
if (health < -6)
{
age = 100;
cout << "他只是默默的看着你,然后走了" << endl;
}
}
/*6. 喂食函数feed()
饥饿值-1;
行动点数-5;
*/
void feed() //喂食函数
{
hunger--;
movepoint = movepoint - 5;
}
/*7. 喂水函数drink()
口渴度-1;
行动点数-3*/
void drink() //喂水函数
{
thirsty--;
movepoint = movepoint - 3;
}
/* 8. 看医生函数doctor()
行动点-10*/
void doctor()
{
movepoint = movepoint - 10;
}
/*9. 抚摸函数touch(w)
抚摸(消耗3点行动力,天气w)。
w=0,心情+2;
w=1、w=2,心情+1;
w=3,心情-1,口渴-1;
w=4,心情-1,饥饿值-1;*/
void touch(int w) //w为天气
{
movepoint = movepoint - 3;
switch (w)
{
case 0:
mood = mood + 2;
break;
case 1:
mood++;
break;
case 2:
mood++;
break;
case 3:
mood--;
thirsty--;
case 4:
mood--;
hunger--;
}
}
/*10. 玩耍函数fun(w)
玩耍(消耗8点行动力,受天气w影响)。
w=0,心情+2;
w=1,心情+1;
w=2,饥饿值+1,口渴值+1,健康值+1;
w=3,饥饿值+2,口渴值+1,健康值+1;
w=4,饥饿值+1,口渴值+1,健康+1;*/
void fun(int w)
{
movepoint = movepoint - 8;
switch (w)
{
case 0:
mood = mood + 2;
case 1:
mood++;
case 2:
hunger++;
thirsty++;
health++;
case 3:
hunger = hunger + 2;
thirsty++;
health++;
case 4:
hunger++;
thirsty++;
health++;
}
}
void playing()
{
movepoint = movepoint + 3;
int m, n;
srand(time(NULL));
n = rand() % 100;
cout << "主人我们来进行猜数字游戏吧" << endl;
cout << "游戏规则是我在心里想一个数字,注意这个数字在0-100之间" << endl;
cout << "然后主人您才,如果能对了,我会告诉您,如果您猜大了或者您猜小了我都会给您提示" << endl;
cout << "go!!!!" << endl;
cout << "主人请输入您猜的数字" << endl;
while (cin >> m)
{
if (m == n)
{
cout << "恭喜您猜对了,我的主人" << endl;
break;
}
if (m<n)
{
cout << "哎呀,主人你猜小了" << endl;
}
if (m>n)
{
cout << "哎呀主人您猜大了" << endl;
}
}
mood++;
hunger--;
}
void playing1()
{
movepoint = movepoint + 3;
int bb;
int ans = 0;
srand(time(NULL));
N = rand() % 6;
M = rand() % 10;
cout << "这个游戏是有一个大小为N*M的园子,雨后积了很多水。八连通的积水被认为是在一起的。请求出园子里共有多少个水洼?(八连通是指相邻的八个方向)" << endl;
cout << "现在在给您图" << endl;
for (int i = 0; i<N; i++)
{
for (int j = 0; j<M; j++)
{
field[i][j] = a[rand() % 2];
}
}
for (int i = 0; i<N; i++)
{
for (int j = 0; j<M; j++)
{
cout << field[i][j];
}
cout << endl;
}
cout << "请您猜数字" << endl;
while (cin >> bb)
{
for (int i = 0; i<N; i++)
{
for (int j = 0; j<M; j++)
{
if (field[i][j] == 'W')
{
//从有w的地方开始dfs
dfs(i, j);
ans++;
}
}
}
if (bb != ans)
{
cout << "你真是个大笨蛋" << endl;
cout << "算了人家再给你次机会" << endl;
}
if (bb == ans)
{
cout << "男朋友你好厉害啊!!!" << endl;
break;
}
}
}
void playing2()
{
movepoint = movepoint + 3;
int i, j;
char a[1000];
cout << "手机的键盘是这样的:" << endl;
cout << "1 2 abc 3 def" << endl;
cout << "4 ghi 5 jkl 6 mno" << endl;
cout << "7 pqrs 8 tuv 9 wxyz" << endl;
cout << "* 0 #" << endl;
cout << "要按出英文字母就必须要按数字键多下。例如要按出x就得按9两下,第一下会出w,而第二下会把w变成x。0键按一下会出一个空格。" << endl;
cout << "你的任务是读取若干句只包含英文小写字母和空格的句子,求出要在手机上打出这个句子至少需要按多少下键盘。" << endl;
char b[29] = { ' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' };
cout << "现在给您这些字母你去猜,哈哈哈" << endl;
srand(time(NULL));
for (i = 0; i<29; i++)
a[i] = b[rand() % 29];
for (i = 0; i<29; i++)
cout << a[i];
cout << "主人请输入您猜的数字" << endl;
while (cin >> j)
{
int length, ans = 0;
length = strlen(a);
for (int i = 0; i<length; i++)
{
ans += tim(a[i]);
}
if (j != ans)
cout << "呵呵,伦家再给你次机会" << endl;
if (j == ans)
{
cout << "n男朋友你真棒" << endl;
break;
}
}
}
void daguai()
{
mood++;
int t;
cout << "您可以选择一下的boss 1,吕布,2,项羽,3,西门飞雪" << endl;
cout << "请您选择" ;
cin >> t;
switch(t)
{
case 1:
cout <<"您选择打的是吕布,吕布有以下几个技能1,温侯连环戟2,十方横扫3,刚愎4,无双" << endl;
lvbu();
break;
case 2:
cout <<"您选择打的是项羽,项羽有以下几个技能1,剑刃风暴2,剑气3,剑舞4,鬼雄" << endl;
xiangyu();
break;
case 3:
cout <<"您选择打的是西门飞雪,西门飞雪有以下几个技能1,落花飞雪2,追风剑3,追魂剑4,天外飞仙" << endl;
ximenfeixue();
break;
}
}
virtual int getl()
{
return age;
}
virtual void action(int act, int w, int emg) = 0;
/*派生类应当增加寿命,实现action方法。
action(act,w,emg)
0:饲养说明,1.喂食,2.喂水,3.抚摸,4玩耍,5什么也不做,6看病*/
};
void instruction()
{
cout << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
cout << "+饲养说明: +" << endl;
cout << "+每个时间段作为主人的你新增5点行动点,未用完可以累积到下一时段,初始有50点。 +" << endl;
cout << "+当行动点相当低时,出现bad end,饲养结束。 +" << endl;
cout << "+每天有三个时间段,你可以进行5项操作,喂食、喂水、抚摸、玩耍、不做任何事、玩猜数字大小游戏、数洼地、还有比较难的算手机按键游戏。 +" << endl;
cout << "下面介绍一下打怪,每打一次怪无论输赢,宠物心情加一,饥饿度加二,口渴度加二 +" << endl;
cout << "+行动点对应消耗:喂食5点,喂水3点,抚摸3点,玩耍8点。玩猜数字大小游戏、数洼地、还有比较难的算手机按键游戏。各加三点行动点 +" << endl;
cout << "+打怪游戏中有三个boss,分别是吕布项羽和西门飞雪,在打怪游戏中默认生命值为100,默认行动点为30 +" << endl;
cout << "+现在介绍一下宠物以及boss的技能,宠物的技能1,宠物顶计2,宠物快跑3,萌系诱饵4,免疫奶瓶 +" << endl;
cout << "+宠物顶计消耗2点技能点,造成20点伤害,宠物快跑消耗4点消耗值,造成20点伤害,萌系诱饵造成20点伤害消耗5点,免疫奶瓶分别是30,6. +" << endl;
cout << "+选择不做任何事,则跳到下一时间段。 +" << endl;
cout << "+当饥饿与口渴相当低的时候,或者健康指数相当低的时候,会出现bad end,宠物死亡。 +" << endl;
cout << "+当宠物年龄到达寿命极限时,出现happy end,宠物寿终正寝。 +" << endl;
cout << "+PS:不同的天气对宠物的心情和健康又影响。 +" << endl;
cout << "+在不同天气中进行抚摸玩耍会有特殊情况发生,请注意。 +" << endl;
cout << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
}
class rabbit :virtual public pet
{
int life;
public:
rabbit(int l = 28)
{
life = l;
}
int getl()
{
return life;
}
void action(int act, int w, int emg)
{
switch (act)
{
case 0:
instruction();
break;
case 1:
feed();
break;
case 2:
drink();
break;
case 3:
touch(w);
break;
case 4:
fun(w);
case 5:
cout << "什么也不做" << endl;
break;
case 10:
emg = 0;//清零
doctor();
break;
case 6:
playing();
break;
case 7:
playing1();
break;
case 8:
playing2();
break;
case 9:
daguai();
}
}
};
class horse :virtual public pet
{
int life;
public:
horse(int l = 52)
{
life = l;
}
int getl()
{
return life;
}
void action(int act, int w, int emg)
{
switch (act)
{
case 0:
instruction();
break;
case 1:
feed();
break;
case 2:
drink();
break;
case 3:
touch(w);
break;
case 4:
fun(w);
break;
case 5:
cout << "什么也不做" << endl;
break;
case 10:
emg = 0;//清零
doctor();
break;
case 6:
playing();
break;
case 7:
playing1();
break;
case 8:
playing2();
break;
case 9:
daguai();
}
}
};
class niu :virtual public pet
{
int life;
public:
niu(int l = 28)
{
life = l;
}
int getl()
{
return life;
}
void action(int act, int w, int emg)
{
switch (act)
{
case 0:
instruction();
break;
case 1:
feed();
break;
case 2:
drink();
break;
case 3:
touch(w);
break;
case 4:
fun(w);
break;
case 5:
cout << "什么也不做" << endl;
break;
case 10:
emg = 0;//清零
doctor();
break;
case 6:
playing();
break;
case 7:
playing1();
break;
case 8:
playing2();
break;
case 9:
daguai();
break;
}
}
};
/*五. 时间函数和天气函数
时间函数:表示一天的3个时间段,0表示上午,1表示下午,2表示晚上
天气函数:使用随机数生成0~4之间的数,0:晴,1:阴,2:小雨,3暴雨,4:大风。*/
void period(int t)
{
t = t % 3;
switch (t)
{
case 0:
cout << "上午" << endl;
break;
case 1:
cout << "下午" << endl;
break;
case 2:
cout << "晚上" << endl;
break;
}
}
int weather() //天气函数
{
int w;
w = rand() % 5;
switch (w)
{
case 0:
cout << "天气:晴。" << endl;
break;
case 1:
cout << "天气:阴。" << endl;
break;
case 2:
cout << "天气:小雨。" << endl;
break;
case 3:
cout << "天气:暴雨。" << endl;
break;
case 4:
cout << "天气:大风。" << endl;
break;
}
return w;
}
int raise(int select)
{
int life, date, w, act;
int t = 0;
int emg, newstep, newage;
pet *petc; //动态建立对象,实现领养
switch (select)
{
case 1:
petc = new rabbit;
break;
case 2:
petc = new horse;
break;
case 3:
petc = new niu;
break;
}
life = petc->getl();
for (date = 1; date<life; date++)
{
cout << "今天是您领养的第" << date << "天" << endl;
w = weather(); //调用天气函数
t = t % 3;
petc->p2();
while (t<3)
{
cout << "现在的时间段是" << endl;
period(t);
srand(time(NULL));
emg = rand() % 21;
cout << "-------------------------------------------------------------------------------------------------------------------" << endl;
do
{
newstep = petc->getmovepoint();
cout << "您的行动点数还有:" << newstep << endl;
cout << "您的宠物当前的状态";
petc->show();
cout << "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
if (emg == 20)
cout << " 宠物现在的健康状况:生病" << endl;
else
cout << " 宠物现在的健康状况:良好" << endl;
cout << "请选择你想做的事:" << endl;
cout << "0、参看说明 1、喂食 2、喂水 3、抚摸 4、逗它玩耍 5、不做任何事"
<< "6、猜数字大小游戏7、算数洼地的个数8、手机键盘输入游戏,9、宠物打怪";
if (emg == 20)
cout << " 10、看医生。" << endl;
else
cout <<"----------------------------------------------------------------------------" << endl;
cout << "请选择您的操作:";
cin >> act;
cout << "-------------------------------------------------------------------------------" << endl;
petc->action(act, w, emg);
cout << "----------------------------------------------------------------------------------------"<<endl;
}
while (act!=5);
petc->emergency(emg);
cout << "--------------------------------------------------------------" << endl;
newage = petc->getage();
if (newage>life)
{
cout << "-------------------------------------------------------------------------------" << endl;
cout << "由于您的疏忽您的宠物非正常死亡!!!!!bad end" << endl;
cout << "-------------------------------------------------------------------------------" << endl;
break;
}
if (newstep<0)
{
cout << "-------------------------------------------------------------------------------" << endl;
cout << "bad end 呵呵,你真鸡儿厉害,还养宠物,真他妈不负责任,你知道从责任俩字咋写么??来来我告诉你" << endl;
cout << "-------------------------------------------------------------------------------" << endl;
break;
}
t++;
cout << "-------------------------------------------------------------------------------" << endl;
}
if (newage>life || newstep<0)
{
cout <<"-------------------------------------------------------------" << endl;
cout << "非正常死亡 bad end" << endl;
cout << "--------------------------------------------------------------" << endl;
break;
}
}
if (date == life)
{
cout << "-------------------------------------------------------------------------------" << endl;
cout << "恭喜,你的宠物已经寿终正寝。" << endl;
cout << "-------------------------------------------------------------------------------" << endl;
}
return 0;
}
void petshop(int w)
{
if (w == 1)
{
cout << " ( ( ( " << endl;
cout << " ) ) _..-.._ " << endl;
cout << " __)/ ,*,* *. " << endl;
cout << " ,* ** ,--. *. " << endl;
cout << " ,* 0 *' * " << endl;
cout << " (Y ( ;**. " << endl;
cout << " *--.____, , ; " << endl;
cout << " ((_ ,----* ,---* _,*_,* " << endl;
cout << " (((_,- (((______,-* " << endl;
cout << "-------------------------------------------------------------------------------" << endl;
}
if (w == 2)
{
cout << " ~~%%%%%%%%_,_, " << endl;
cout << " ~~%%%%%%%%%-*/./ " << endl;
cout << " ~~%%%%%%%-* / *. " << endl;
cout << " ~~%%%%%%%%* . ,--; " << endl;
cout << " ~~%%%%%%%%* : O " << endl;
cout << " ~~%%%%%%%%* : *. " << endl;
cout << " ~~%%%%%%%%* *. -, * " << endl;
cout << " ~~%%%%%%%%* .**-.- *. " << endl;
cout << " ~~%%%%%%%%%* : *-. (,; " << endl;
cout << " ~~%%%%%%%%* : *.--.* " << endl;
cout << " ~~%%%%%%%* ; " << endl;
cout << "-------------------------------------------------------------------------------" << endl;
}
if (w == 3)
{
cout << "-------------------------------------------------------------------------------" << endl;
cout << " /~~~~/ /~~~~/ " << endl;
cout << " / / / / " << endl;
cout << " | |_____| | " << endl;
cout << " /~ ~/ " << endl;
cout << " /~~~~~-_| /~~/ /~~~/ |_-~~~~~ " << endl;
cout << " / ==== /| | O| |O | |/ ==== / " << endl;
cout << " ~-__-~ | |_---+--+----_| | ~-__-~ " << endl;
cout << " |/~ ~/| " << endl;
cout << " / / " << endl;
cout << " ( O O ) " << endl;
cout << " / ./ " << endl;
cout << " ~-__________-~| " << endl;
cout << " | |/__/| | " << endl;
cout << " | |/~~/| | " << endl;
cout << " | /~~~~~~~~~/ | " << endl;
cout << " | | | | " << endl;
cout << " | | | | " << endl;
cout << "-------------------------------------------------------------------------------" << endl;
}
}
/*二. 领养函数(adopt):实现领养功能,返回所选的宠物。
1. 说明宠物的种类
2. 选择宠物(调用petshop函数)
3. 给宠物起名字
4. 查看饲养说明(调用instruction函数)
5. 返回所选宠物的种类
*/
int adopt()
{
int hc, b;
char name[20];
cout << "现在宠物店里面还有这些可选择的宠物 1.小兔子,2,小马驹,3.大牛 " << endl;
cout << "请输入您的选择" << endl;
cin >> hc;
petshop(hc);
cout << "再给您的宠物七个名字呗" << endl;
cin >> name;
cout << "恭喜您领养了一只名为" << name << "的宠物" << endl;
cout << "您是否杨查看饲养说明 是 1,否 2" << endl;
cin >> b;
if (b == 1) instruction();
return hc;
}
int main()
/*主函数main:实现整个函数的循环
调用领养函数(adopt),返回所选的种类。
判断是否开始饲养。
调用饲养函数(raise),传入所选宠物。
判断是否继续领养宠物(即判断是否跳出循环)
*/
{
int ch, a, sel, choose = 0;
while (choose == 0)
{
sel = adopt();
cout << "您是否开始选择领养的宠物,是 1,否 2" << endl;
cout << "您的选择是" << endl;
cin >> ch;
if (ch == 1)
{
raise(sel);
}
cout << "是否继续领养宠物 是 1,否 2" << endl;
cin >> a;
choose = a - 1;
}
return 0;
}
相关知识
汽车电子ISO7637
电子宠物
ToumaPet 拍照电子宠物机,电子宠物游戏机,电子宠物机,宠物游戏机
什么是电子宠物?电子宠物APP怎么开发?
电子宠物下载
桌面电子宠物
什么是电子宠物?电子宠物到底是游戏还是人工智能
电脑电子宠物供应商,价格,电脑电子宠物批发市场
电子宠物 Hatchi
电子宠物大作战在哪里玩?电子宠物大作战详细攻略
网址: 电子宠物+原创 https://m.mcbbbk.com/newsview324590.html
上一篇: Java 中 == 和 equa |
下一篇: python打印一定范围内的素数 |