有一只鸟,有自己的特征:姓名, 种类,性别,年龄,体重,生活区域,喜欢吃的食物
有天,小鸟因不小心出了事故,忘了所有的事情,(方法一:所有属性值还原为默认)
这天,小鸟痊愈后,找到了他的妈妈,妈妈告诉他之前的事情,他叫小黄,是只布谷鸟,是一只活泼可爱的女鸟,他今年2个月了,已经有1.5斤了,喜欢在森林里呆着,喜欢吃谷子 (方法二,给所有属性赋值)
渐渐的,小黄需要找男朋友了,如果对方的年龄在4个月以上,而且他的资产在1000鸟币以上,他就同意结婚,如果对方年纪在2到4个月之间,而且他的资产在500鸟币以上,他会考虑一个月,再决定,如果对方年纪在2个月以下, 他会拒绝 (方法三)
不久小黄结婚了,我们来看一下,小黄会不会饿肚子!小黄和老公每天都要吃10粒谷子才不会饿到!小黄每天捉到的谷子有30%来喂养孩子,40%储备过冬,10%孝敬老人,剩下的跟老公一块分享,而老公每天捉到的谷子10%储备过冬,50%孝敬老人, 20%喂养孩子,剩下的跟小黄一块分享....这天,小黄捉了30粒谷子,老公捉了43粒,他们会饿着嘛? (方法四)
using System;
namespace Zuoye_BuGuNiao
{
class MainClass
{
public static void Main (string[] args)
{
Bird boyfriend=new Bird();
Console.WriteLine("输入小黄目标男朋友的年龄:(整数月份)");
string age1=Console.ReadLine();
boyfriend.age = int.Parse (age1);
Console.WriteLine("输入小黄目标男朋友的资产:(整数)");
string wea=Console.ReadLine();
boyfriend.wealth = int.Parse (wea);
boyfriend.merry();
Bird husband=new Bird();
husband.IsHunger(43f,30f);
}
}
class Bird
{
public string type;
public string name;
public bool sex;
public int age;
public string living;
public string food;
public int wealth;
public void MoRen(){
type=" ";
name=" ";
sex = false;
age = 0;
living=" ";
food=" ";
}
public void HuiFu(){
type="BuguBird";
name="xiaohuang";
sex = true;
age = 2;
living="forest";
food="guzi";
}
public void merry(){
if(age<2)Console.WriteLine("Sorry,refuse");
else if(age<4&&wealth>500)Console.WriteLine("Consider a month!");
else if(wealth>1000) Console.WriteLine("Agree to merry!");
else Console.WriteLine("Sorry,refuse");
}
public void IsHunger(double gu1,double gu2){
double a1, a2;
a1 = gu1 * (1 - 0.3 - 0.4 - 0.1);
a2 = gu2 * (1 - 0.1 - 0.5 - 0.2);
if(a1+a2>=20)Console.WriteLine("Do not hunger!");
else Console.WriteLine("Hunger!");
}
}
}