--------------------------------------角色类--------------------------------------
1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Threading.Tasks; 6 7 namespace J5.entity 8 { 9 class Role 10 { 11 public Role(int live) 12 { 13 this.Live = live; 14 Console.WriteLine("创建成功,血量:" + live); 15 } 16 public Role(int level, int power, int live) 17 { 18 this.Live = live; 19 this.Level = level; 20 this.Power = power; 21 Console.WriteLine("创建成功,等级:{0},战斗力{1}:,血量:{2}",level,power, live); 22 } 23 public string Name { get; set; } 24 public int Level { get; set; } 25 public int Power { get; set; } 26 public int Live { get; set; } 27 } 28 }
--------------------------------------Main方法--------------------------------------
1 using J5.entity; 2 using System; 3 using System.Collections.Generic; 4 using System.Linq; 5 using System.Text; 6 using System.Threading.Tasks; 7 8 namespace J5 9 { 10 class Program 11 { 12 static void Main(string[] args) 13 { 14 Role r = new Role(10000); 15 16 Role r1 = new Role(999,999999,9999999); 17 } 18 } 19 }