面向对象的小程序折腾
来源:互联网 发布:淘宝评价超过15天 编辑:程序博客网 时间:2024/06/06 02:39
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace 技术折腾
{
class Program
{
static void Main(string[] args)
{
Pat p = new Pat();
bool result = true;
while (result)
{
Console.WriteLine("请选择:1.聊天 2.喂东西 3.运动 4.退出");
Console.WriteLine("Health:{0} fullLevel:{1} ", p.Health, p.FullLevel);
switch (Console.ReadLine())
{
case "1":
p.Chat();
break;
case "2":
p.Eat();
break;
case "3":
p.Play();
break;
case "4":
Console.WriteLine("按任意键退出程序......");
Console.ReadKey();
result = false;
break;
default:
Console.WriteLine("输入错误 !请重新输入!");
break;
}
}
}
}
class Pat
{
private int health=20;
public int Health
{
set { value = health; }
get { return health; }
}
private int amount = 0;
public int Amount
{
get { return amount; }
set { amount = value; }
}
private int fullLevel = 20;
public int FullLevel
{
set { value = fullLevel; }
get { return fullLevel; }
}
public void Eat()
{
if (fullLevel > -1&health>0)
{
Console.WriteLine("请输入要喂的数量");
amount = Convert.ToInt32(Console.ReadLine());
if (amount > 3)
{
fullLevel = -1;
Console.WriteLine("吃的太多了,撑死了!");
}
else if (amount < 0)
{
Console.WriteLine("你是上帝派来玩我的吧!");
}
else
{
fullLevel = fullLevel + amount;
health = health - 2;
}
}
else
{
Console.WriteLine("本猫已死,有事烧纸!");
}
}
public void Play()
{
if (fullLevel < -1||health<0)
{
Console.WriteLine("本猫已死,有事烧纸!");
}
else
{
health = health + 5;
fullLevel = fullLevel - 2;
}
}
public void Chat()
{
if (this.fullLevel >= 0&health>-1)
{
fullLevel = fullLevel - 2;
health = health + 2;
Console.WriteLine("想聊点什么?都是你消费!");
string str=Console.ReadLine();
if (str.Contains("你妹") || str.Contains("你妈"))
{
Console.WriteLine("请文明用语!");
}
else
{
fullLevel = fullLevel - 2;
health = health + 1;
Console.WriteLine("我叫小手手!非常高兴认识你!");
}
}
else
{
if (fullLevel > -1)
{
Console.WriteLine("我饿了,想吃东西了!");
}
else
{
Console.WriteLine("本猫已死,有事烧纸!");
}
}
}
}
}
- 面向对象的小程序折腾
- 小白程序媛的进击之路(面向对象)
- 初学JAVA面向对象最应该看的小程序
- 小感想 | 面向对象和非面向对象程序的区别是什么?
- 面向对象的程序
- 数猴子小程序(面向对象版)
- 面向对象的小概念
- java运用面向对象的思想实现计算器的小程序
- 面向对象程序编程,自己之前不知道的小知识,学习笔记
- 面向对象的一点小的收获
- 面向对象语言的理解---小笔记
- 面向对象设计的小例子
- 熟悉oc面向对象的小例子
- js面向对象的一些小练习
- 关于面向对象的一点小理解
- 第18天 Java面向对象小程序(二)
- DOM对象的小程序
- 面向对象小练习
- poj4047 线段树
- Oracle EBS R12 客户表结构
- jabberd编译安装
- C语言程序的内存布局
- 分布式搜索elasticsearch java API 之(五)------搜索
- 面向对象的小程序折腾
- mysql5.1安装图解
- map,collection Arraylist 总结
- 使用bat文件自带jre执行jar文件
- 【C++】虚基类的应用实例【原创技术】
- vb 与 .accdb 格式的access数据库的连接方法
- UITableView划动删除的实现
- linux驱动——input输入子系统(1)—输入子系统核心层(Input Core)
- ios多线程