基础,借用一下偶像名字,嘿嘿
来源:互联网 发布:nokia n8软件下载 编辑:程序博客网 时间:2024/04/30 08:03
我当时初学的时候还不理解这些,到后再去看的时候真的闭眼都能写。。。
1.定义一个男人类 声明男人属性 必须男人持有的属性 并且要求在创建男人对象调用机构函数给男人属性赋值
//2.定义一个女人类 声明女人特有的属性 在女人类里面定义一个人方法 方法的返回值bool 参数类型是一个男人对象
//调用是要在START方法去调用
//在人类里面定一个方法 定义一个返回工资的方法
//调用方法去拿工资和价格进行比较 显示比较结果
usingUnityEngine;
usingSystem.Collections;
publicclassNanrenNvren:MonoBehaviour{
// Use this for initialization
voidStart () {
//调用Man类里面的方法
//创建一个对象,实例化
ManhuaZai =newMan("刘德华","男",100000000000000000);
WomanxiaoHong =newWoman();
print( xiaoHong.isMarry(huaZai));
}
// Update is called once per frame
voidUpdate () {
}
}
//定义男人类
publicclassMan
{
publicstringName;
publicstringAge;
publicstringSex;
publiclongMoney;
publicstringChouYan;
publicstringHuZi;
//声明构造函数
publicMan(stringname,stringsex,longmoney)
{
this.Name = name;
this.Sex = sex;//this 可以省略
this.Money = money;
}
}
//定义女人类
publicclassWoman
{
publicstringName;
publicstringAge;
publicstringSex;
publiclongMoney;
publicstringChangFa;
publicstringGuiMi;
// protected 受保护的
publicboolisMarry(Man a )
{
if(a.Money>900000)
{
if(a.Name=="刘德华")
{
returntrue;
}
else
{
Debug.Log("你不是XXX,我不要");
returnfalse;
}
}
else
{
Debug.Log("钱不够");
returnfalse;
}
}
}
阅读全文
0 0
- 基础,借用一下偶像名字,嘿嘿
- 借用一下界面
- “谁有香水,借用一下。”
- 开张了,玩一下,嘿嘿
- 嘿嘿、又一张,自我陶醉一下
- 偶像!
- 今天开张,自己庆祝一下 嘿嘿 :)
- 虫子发挥一下想象 ,背一下韩国基本字母。嘿嘿 。
- 偶像!偶像!!
- 嘿嘿
- 嘿嘿
- 嘿嘿
- 嘿嘿
- 嘿嘿
- 嘿嘿
- 嘿嘿
- 嘿嘿
- 嘿嘿
- Spring Boot的启动器Starter详解
- 《剑指offer》笔记-第6章(1)
- 2017年校招全国统一模拟笔试(第五场)偶串
- c++基础之输入(scanf)和输出(printf)
- hdu 1856
- 基础,借用一下偶像名字,嘿嘿
- MySQL 大表优化方案
- 外接设备连接电脑万能驱动安装
- python爬虫学习第三十三天
- [机器学习实验1]Linear Regression
- 一个月的晨读小总结
- 关于vue 框架与后台框架的混合使用的尝试
- 改进遗传算法
- 1.LINUX基础命令01