91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 2.9MB
    文件類型: .zip
    金幣: 2
    下載: 0 次
    發布日期: 2023-09-21
  • 語言: C/C++
  • 標簽: pet??

資源簡介

學了一個學期,自己寫的一個電子寵物小程序,初次發表,代碼簡單,適合初學c++的同志參考。

資源截圖

代碼片段和文件信息

#include
#include
#include?

using?namespace?std;

class?Pet
{
public:
void?change_with_time(int?w);????//隨時間變化函數
void?display();
void?eat();
void?drink();
void?doctor();
void?touch(int?w);
void?play(int?w);
void?named();
int?emg();
virtual?int?get_life();????//提取壽命值(虛函數)
virtual?void?action(int?act?int?w)?=?0;??//主人行為函數(純虛)
virtual?void?show()=0;??//?顯示寵物圖像
Pet(int?a?=?0?int?hy?=?0?int?th?=?0?int?m?=?0?int?he?=?0?int?sp?=?20)
{
age?=?a;
hungry_index?=?hy;
thirsty_index?=?th;
health_index?=?he;
mood_index?=?m;
step_points?=?sp;
}

void??get_named()
{
cout?< }
int?get_step_points()
{
return?step_points;
}
int?get_health_index()
{
return?health_index;
}
int?get_mood_index()
{
return?mood_index;
}
int?get_thirsty_index()
{
return?thirsty_index;
}
int?get_hungry_index()
{
return?hungry_index;
}
void?reduce()
{
hungry_index++;
thirsty_index++;
}
void?add_step_points()
{
step_points?+=?5;
}
private:
int?age;?????????????????//年齡
string?name;?????????????//名字
int?hungry_index;?????????//饑餓度
int?thirsty_index;????????//口渴度
int?mood_index;???????????//心情
int?health_index;?????????//健康度
int?step_points;??????????//行動點數
};

int?Pet::get_life()
{
return?age;
}

void?Pet::play(int?w)
{
switch?(w)
{
case?0:
mood_index?+=?2;
break;
case?1:
mood_index?+=?1;
break;
case?2:
hungry_index?+=?1;
thirsty_index?+=?1;
health_index?+=?1;
break;
case?3:
hungry_index?+=?2;
thirsty_index?+=?1;
health_index?+=?1;
break;
case?4:
hungry_index?+=?1;
thirsty_index?+=?1;
health_index?+=?1;
break;
default:
break;
}
step_points?-=?8;
}
//撫摸函數?
void?Pet::touch(int?w)
{
switch?(w)
{
case?0:
mood_index?+=?2;
break;
case?1:
case?2:
mood_index?+=?1;
break;
case?3:
thirsty_index?+=?1;
break;
case?4:
mood_index?-=?1;
hungry_index?+=?1;
break;
default:
break;
}
step_points?-=?3;

}

//展示寵物狀態
void?Pet::display()
{
cout?< cout?< cout?< cout?< cout?< system(“pause“);
}
//特殊狀態
int?Pet::emg()
{
int?x;
srand((int)time(0));
x?=?rand()?%?21;
if?(x?==?21)
{
cout?< health_index?-=2;
}
if?(get_hungry_index()?==?3)
{
mood_index?-=?1;
cout?< }
else?if?(get_hungry_index()?==?-2)
{
mood_index?-=?1;
cout?< }
else?if?(get_hungry_index()?>?3)
{
mood_index?-=?1;
cout?< }
else?if?(get_hungry_ind

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2017-03-23?10:57??pet-li\
?????目錄???????????0??2017-03-23?10:57??pet-li\Debug\
?????文件???????97792??2017-03-23?10:28??pet-li\Debug\pet-li.exe
?????文件?????1087092??2017-03-23?10:28??pet-li\Debug\pet-li.ilk
?????文件?????1575936??2017-03-23?10:28??pet-li\Debug\pet-li.pdb
?????目錄???????????0??2017-03-23?10:57??pet-li\pet-li\
?????文件?????7274496??2017-03-23?10:51??pet-li\pet-li.sdf
?????文件?????????964??2017-03-20?08:22??pet-li\pet-li.sln
?????文件???????22528??2017-03-23?10:51??pet-li\pet-li.v12.suo
?????目錄???????????0??2017-03-23?10:57??pet-li\pet-li\Debug\
?????文件????????1997??2017-03-23?10:28??pet-li\pet-li\Debug\pet-li.log
?????文件??????274954??2017-03-23?10:28??pet-li\pet-li\Debug\pet-li.obj
?????目錄???????????0??2017-03-23?10:57??pet-li\pet-li\Debug\pet-li.tlog\
?????文件?????????582??2017-03-23?10:28??pet-li\pet-li\Debug\pet-li.tlog\cl.command.1.tlog
?????文件????????5712??2017-03-23?10:28??pet-li\pet-li\Debug\pet-li.tlog\CL.read.1.tlog
?????文件?????????356??2017-03-23?10:28??pet-li\pet-li\Debug\pet-li.tlog\CL.write.1.tlog
?????文件????????1030??2017-03-23?10:28??pet-li\pet-li\Debug\pet-li.tlog\link.command.1.tlog
?????文件????????2262??2017-03-23?10:28??pet-li\pet-li\Debug\pet-li.tlog\link.read.1.tlog
?????文件?????????330??2017-03-23?10:28??pet-li\pet-li\Debug\pet-li.tlog\link.write.1.tlog
?????文件?????????154??2017-03-23?10:28??pet-li\pet-li\Debug\pet-li.tlog\pet-li.lastbuildstate
?????文件??????265216??2017-03-23?10:28??pet-li\pet-li\Debug\vc120.idb
?????文件??????389120??2017-03-23?10:28??pet-li\pet-li\Debug\vc120.pdb
?????文件???????16688??2017-03-23?10:28??pet-li\pet-li\pet-li.cpp
?????文件????????4018??2017-03-20?09:48??pet-li\pet-li\pet-li.vcxproj
?????文件?????????947??2017-03-20?09:48??pet-li\pet-li\pet-li.vcxproj.filters

評論

共有 條評論