//我来写个电子狗的完完吧,稍微等一下哦。
//简单的电子狗哦。领养5秒以后开始运作~
#include "iostream.h"
#include "windows.h"
#include "math.h"
class DOG
{
public:
char name[20];
int health;
int clean;
int hungruy;
DOG();
~DOG();
void _health(void);
void _clean(void);
void _hungruy(void);
void _search(void);
void sd();
};
void DOG::_health()
{ int choose=-1;
cout<
if(choose==1)
{
health=health+10;
cout<<"你的宠物狗 "<
}
void DOG::_clean()
{
int choose=-1;
cout<
if(choose==1)
{
clean=clean+10;
cout<<"你的宠物狗 "<
}
void DOG::_hungruy()
{
int choose=-1;
cout<
if(choose==1)
{
hungruy=hungruy+10;
cout<<"你的宠物狗 "<
}
DOG::DOG()
{
cout<<"请输入小狗的名称"<
health=50;
clean=50;
hungruy=50;
cout<<"小狗圈养完成"<
}
////////////////////
void DOG::sd()
{
int i,j;
for(i=0;i<3;i++)
{
j=1+(int)(10.0*rand()/(RAND_MAX+1.0));
switch(j)
{
case 0:
health=health-10;
cout<<"您的小狗 "<
case 1:
clean=clean-10;
cout<<"您的小狗 "<
case 2:
hungruy=hungruy-10;
cout<<"您的小狗 "<
}
}
}
void DOG::_search()
{
if(health<50) _health();
if(clean<50) _clean();
if(hungruy<50) _hungruy();
cout<<"检查完毕!"<
DOG::~DOG(){}
//////////////////////
/////////////////////
void main()
{
int num=0;
cout<<"请输入圈养小狗的数目"<
DOG *p=new DOG[num];
for(int i=0;i
Sleep(5000);
for(int j=0;j
p[i].sd();
p[i]._search();
}
}
}
本来想回答你这些问题的,可看到里面有很多不通的语法,什么叫C++三门课,什么叫某上苍某天等等.这些东西很让我费解.
一般人是没这个耐性的,LZ放弃吧