c++程序设计电子宠物.docxVIP

  • 22
  • 0
  • 约8.95千字
  • 约 14页
  • 2020-01-15 发布于江苏
  • 举报
#include iostream #include stdlib.h using namespace std; class pet // 建立一个宠物类 { public: pet(int a=0,int h=0,int t=0,int m=0,int he=0,int st=15) // 构造函数 {age=a;hunger=h;thirst=t;mood=m;health=he;step=st;} int geta() {return age;} //提取各个私有成员 int geth() {return hunger;} int gett() {return thirst;} int getm() {return mood;} int gethe() {return health;} int getst() {return step;} void p2(); // 饥饿、口渴以及心情随时间的变化函数 void show(); // 各个数值的输出函数 void emergency(int w); //各种特殊状态函数 void feed() // 喂食函数 { hunger--; step=step-5; } void drink() {thirst--;step=step-3;} //喂水函数 void doctor() {step=step-10;} // 看医生函数

您可能关注的文档

文档评论(0)

1亿VIP精品文档

相关文档