unit2.cpp

来自「描叙一个人的成长过程」· C++ 代码 · 共 82 行

CPP
82
字号
//---------------------------------------------------------------------------


#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 + =
减小字号Ctrl + -
显示快捷键?