C# 面向对象
葫芦娃大战奥特曼
----显示效果
-----
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication1 { class Monster { public string Name; public int HP = 100; public void Fight(Monster op) { Console.WriteLine(Name+"开始攻击"+op.Name); op.HP-=10; } public void Fight(Monster op,int blood ) { Console.WriteLine(Name + "开始攻击" + op.Name); op.HP -= blood; } public void Show() { Console.WriteLine(Name+";"+HP); } } class Class2 { static void Main(string[] args) { Monster m1=new Monster() ; m1.Name="奥特曼"; Monster m2 =new Monster(); m2.Name="葫芦娃"; m1.Fight(m2); m1.Show(); m2.Show(); } } }