简易恋爱游戏程序 C++
2012-04-21 10:02
501 查看
#include<iostream>
#include<cstring>
using namespace std;
class Boy
{
public:
bool House;
int Age;
char Name[20];
public:
Boy(char *name);
bool Gift(char gift);
int AnnualSalary(int salary);
};
Boy::Boy(char *name)
{
if(rand()==100)
House=true;
strcpy(Name,name);
}
bool Boy::Gift(char gift)
{
if(gift=='Y'||gift=='y')
return true;
else
return false;
}
int Boy::AnnualSalary(int salary)
{
cout<<Name<<"日夜操劳,两眼发黑,为的是早日赚到老婆本。"<<endl;
salary=salary*365;
return salary;
}
class Girl
{
public:
int Feeling;
bool Willing;
int Birthday;
char Name[20];
public:
Girl(char *name);
void Love(char *name);
void Marry(char *name);
};
Girl::Girl(char *name)
{
strcpy(Name,name);
}
void Girl::Love(char *name)
{
cout<<"\n新的故事开始了,"<<Name<<"与"<<name<<"进入相恋阶段…………"<<endl;
}
void Girl::Marry(char *name)
{
cout<<"\n美好结局,"<<Name<<"同意嫁给"<<name<<",从此两人过上了幸福生活……"<<endl;
}
int main()
{
Boy theBoy("Jay");
Girl theGirl("Vivian");
theBoy.Age=24;
theGirl.Feeling=1;
theGirl.Willing=true;
theGirl.Birthday=1224;
int year=1;
char gift='N';
int money=0;
int salary=0;
theGirl.Love(theBoy.Name);
if(theBoy.House==true)
{
theGirl.Marry(theBoy.Name);
return 0;
}
while(theGirl.Willing==true)
{
cout<<"\n* * * * * 第"<<year<<"年 * * * * *\n";
for(int day=1; day<=365; day++)
{
if(day==45)
{
cout<<"情人节到了,是否送给女朋友礼物呢?(Y\\N)";
cin>>gift;
if(theBoy.Gift(gift))
theGirl.Feeling++;
else
theGirl.Feeling--;
}
if(day==350)
{
cout<<"生日到了,是否送给女朋友礼物呢?(Y\\N)";
cin>>gift;
if(theBoy.Gift(gift))
theGirl.Feeling++;
else
theGirl.Feeling--;
}
}
cout<<"请输入今年的日工资:";
cin>>salary;
money=money+theBoy.AnnualSalary(salary);
cout<<"年终小结:\t"<<"男孩年龄:"<<theBoy.Age<<",男孩存款:"<<money<<",女孩情感指数:"<<theGirl.Feeling;
if(money>1000000)
{
theBoy.House=true;
break;
}
year++;
theBoy.Age++;
theGirl.Feeling--;
if(theBoy.Age>30||theGirl.Feeling<0)
theGirl.Willing=false;
}
if(theBoy.House==true)
theGirl.Marry(theBoy.Name);
else
{
Boy anotherBoy("Jahn");
theGirl.Love(anotherBoy.Name);
}
return 0;
}
相关文章推荐
- c++游戏程序移植到android平台后,如何更新程序,重新编译
- C++游戏程序优化
- 简易游戏修改器(C#实现,提供程序下载)
- C++猜数字游戏的程序,用srand()函数才生随机数
- [转]C++游戏程序优化
- 在 C++ 程序中导出 Word 文档的简易方法
- C++游戏程序 - 龟兔赛跑Ⅳ
- 自学C++游戏程序开发学习顺序(转)
- C++游戏之创建第一个窗体程序(一)
- 公司技术管理角度看C++游戏程序发…
- 一个简易的游戏程序
- c/c++程序之_猜数游戏
- C++一个猜数游戏程序
- 从易到难编写C++程序,(7)问题:利用问题(6)的发牌,实现24点游戏
- C++一个猜数游戏程序
- C++游戏程序优化
- 【c++程序】拳击游戏
- 简易聊天程序教程(五)客户端的登陆和注册窗口
- win7C++程序移植到Linux出现的问题
- g++ 编译 c++ 程序时需要包括 include .h 文件,还是需要 .cpp 文件