第四章,简答题4-5,2017-4-6

巫师属性类-------

 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5 using System.Threading.Tasks;
 6 
 7 namespace 第四章_简答题5.entity
 8 {
 9     public class Wus
10     {
11         public int SM { get; set; }//生命
12         public int  Do  { get; set; }//战斗值
13         public int ji { get; set; }//级别
14         /// <summary>
15         /// 默认巫师生命值
16         /// </summary>
17         public Wus() 
18         {
19             SM = 10000;
20         }
21         /// <summary>
22         /// 巫师属性
23         /// </summary>
24         public Wus(int Sm,int DO,int Ji) 
25         {
26             this.SM = Sm;
27             this.Do = DO;
28             this.ji = Ji;
29         }
30         /// <summary>
31         /// 显示巫师属性
32         /// </summary>
33         public void SayHi() 
34         {
35             Console.WriteLine("巫师生命值是:"+this.SM+"战斗值是:"+this.Do+"级别:"+this.ji);
36         }
37 
38     }
39 }

巫师Main----

 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5 using System.Threading.Tasks;
 6 using 第四章_简答题5.entity;
 7 
 8 namespace 第四章_简答题5
 9 {
10     class Program
11     {
12         static void Main(string[] args)
13         {
14             Wus w=new Wus(200000,5000,30);
15             w.SayHi();
16         }
17     }
18 }

蚂蚁类--------

 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5 using System.Threading.Tasks;
 6 
 7 namespace 第四章_简答题4.entity
 8 {
 9     public class ming
10     {
11         public string name { get; set; }
12 
13         public ming(string Name) 
14         {
15             this.name = Name;
16         }
17         public void SayHia() 
18         {
19             Console.WriteLine("我是:"+this.name);
20         }
21     }
22 }
 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5 using System.Threading.Tasks;
 6 
 7 namespace 第四章_简答题4.entity
 8 {
 9     public class tian
10     {
11         public string name { get; set; }
12         public int count { get; set; }
13         public tian(string Name,int Count)
14         {
15             this.name = Name;
16             this.count = Count;
17 
18         }
19         
20         public void SayHi() 
21         {
22             Console.WriteLine("我找到一块甜品:"+this.name);
23             Console.WriteLine("我呼叫到"+this.count+"小伙伴");
24 
25         }
26     }
27 }

蚂蚁main--------

 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5 using System.Threading.Tasks;
 6 using 第四章_简答题4.entity;
 7 
 8 namespace 第四章_简答题4
 9 {
10     class Program
11     {
12         static void Main(string[] args)
13         {
14             ming m = new ming("小不点");
15             m.SayHia();
16             tian t = new tian("hhh", 2);
17             t.SayHi();
18             Console.WriteLine("现在,大家搬家远甜品!");
19             Console.WriteLine("我们完成寻找甜品的任务!");
20         }
21     }
22 }
原文地址:https://www.cnblogs.com/yjjh/p/6676043.html