资源简介
C++代码实现了电子宠物功能,有三种待选择宠物兔子,牛,马,可领养多只,领养之后可进行命名,宠物拥有行动点,每天分为三个时间段早中午,每个时间段会增加5行动点,可以对宠物喂食,喂水,抚摸,玩耍,休息,打工操作。
代码片段和文件信息
#include
#include
#include
#include
#include
using namespace std;
class pet
{
public:
pet(int a=0int hy=0int th = 0int m = 0int he =0int po =20int mo=50string na=“0“)
{
age = a;
hungry = hy;
thirsty = th;
mood = m;
health = he;
points = po;
name = na;
money = mo;
}
int weather();//天气
int change_time();//时间成长函数
void change_with_time(int flg_w);
void is_ill(int emgint death_flag);//是否生病
int speacl();
void drink();//喂水
void eat();//喂食
void touch(int flag_w);//抚摸
void play(int flag_w);//玩耍
int see_doctor(int flag_ill);//看病
void display();//打印
void intitle();//取名
void save();//存档
int read();//读党
void is_continue();//是否选择继续
void choose_play();
void work(int flag_w);
void choose_work();
virtual int get_life()
{
return age;
}
virtual int func(int points)=0;
int get_hungry()
{
return hungry;
}
int get_thirsty()
{
return thirsty;
}
int get_mood()
{
return mood;
}
int get_health()
{
return health;
}
int get_points()
{
return points;
}
string get_pet_name()
{
return name;
}
private:
int age;//天数
int hungry;//饥饿值
int thirsty;//口渴度
int mood;//心情
int health;//健康值
int points;//行动点数
int money;
string name;
};
class rabit:virtual public pet
{
public:
rabit(int l = 31)
{
max_life=l;
}
int get_lfe()
{
return max_life;
}
int func(int points);
private:
int max_life;
};
class horse:virtual public pet
{
public:
horse(int l = 41)
{
max_life=l;
}
int get_lfe()
{
return max_life;
}
int func(int points);
private:
int max_life;
};
class cow:virtual public pet
{
public:
cow(int l = 51)
{
max_life=l;
}
int get_lfe()
{
return max_life;
}
int func(int points);
private:
int max_life;
};
void pet::display()//显示函数
{
cout<<“-------------------------------------------------------------------------------“< cout<<“\t\t***************“< cout< cout< cout<<“饥饿度:“< }
void delay()//打工时间延迟
{
int ij;
int k=1;
for(i=0;i<10;i++)
{
for(j=0;j<10;j++)
{
k++;
cout<<“你的宠物正在打工.....-------------------------->>>>>>>>>“< system(“cls“);
}
}
}
void see_in();//饲养说明的声明
int choose_pet()//选择宠物
{
int chioce=0;
while(1)
{
int j=0;
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 30563 2017-03-22 18:48 电子宠物\main.cpp
文件 1075523 2017-03-23 13:41 电子宠物\main.exe
文件 41478 2017-03-23 13:41 电子宠物\main.o
文件 1408 2017-03-13 15:22 电子宠物\电子宠物.cbp
文件 357 2017-03-13 15:22 电子宠物\电子宠物.layout
文件 23 2018-01-24 14:58 电子宠物\电子宠物.txt
目录 0 2018-06-10 14:47 电子宠物
----------- --------- ---------- ----- ----
1149352 7
相关资源
- Deep Belief Nets in C++ and CUDA C Volume 2 Au
- C++获取计算机的CPU ID,硬盘序列号等
- C++头文件转delphi工具 + 源码
- 国际象棋的qt源代码
- C++中头文件与源文件的作用详解
- C++多线程网络编程Socket
- VC++ 多线程文件读写操作
- 利用C++哈希表的方法实现电话号码查
- 移木块游戏,可以自编自玩,vc6.0编写
- C++纯文字DOS超小RPG游戏
- VC++MFC小游戏实例教程(实例)+MFC类库
- 连铸温度场计算程序(C++)
- 6自由度机器人运动学正反解C++程序
- Em算法(使用C++编写)
- libstdc++-4.4.7-4.el6.i686.rpm
- VC++实现CMD命令执行与获得返回信息
- 白话C++(全)
- C++标准库第1、2
- 大数类c++大数类
- C++语言编写串口调试助手
- c++素数筛选法
- C++ mqtt 用法
- 商品库存管理系统 C++ MFC
- c++ 多功能计算器
- C++17 In Detail
- 嵌入式QtC++编程课件
- 颜色识别形状识别STM103嵌入式代码
- c++ 邮件多附件群发
- c++ 透明代理(hookproxy)
- mfc 调用redis
川公网安备 51152502000135号
评论
共有 条评论