📄 unit2.cpp
字号:
//---------------------------------------------------------------------------
#pragma hdrstop
#include "Unit2.h"
#include "Dialogs.hpp"
//---------------------------------------------------------------------------
#pragma package(smart_init)
void animal::grow()
{
age+=1; //TODO: Add your source code here
}
int animal::getage()
{
return age; //TODO: Add your source code here
}
int animal::setage()
{
age=0; //TODO: Add your source code here
}
//-----------------------------------------------
void person::init()
{
babynum=0;
hasmarry=false;
hasbaby=false;
//TODO: Add your source code here
}
void person::marry()
{
if(hasmarry)
ShowMessage("不要犯重婚罪");
else if(getage()<=20)
ShowMessage("还未到年龄");
else
hasmarry=true; //TODO: Add your source code here
}
void person::babyborn()
{ if (hasmarry)
{
babynum+=1;
hasbaby=true;
}
else
ShowMessage("先去结婚吧"); //TODO: Add your source code here
}
bool person:: getmarry()
{
return hasmarry; //TODO: Add your source code here
}
int person::getbabynum()
{
return babynum; //TODO: Add your source code here
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -