体验套餐管理系统

 1 public  class HealthCheckItem
 2     {
 3        //体检项目类
 4         //保存一个体检项目包括项目名、描述、单价
 5       //例如:肝功能、用于检查肝功能、60
 6       //项目价格
 7       private int price;
 8       //项目描述
 9       private string description;
10       //项目名称
11       private string name;
12       public string Name
13       {
14           get { return name; }
15           set { name = value; }
16       }
17       public string Description
18       {
19           get { return description; }
20           set { description = value; }
21       }
22 
23       public int Price
24       {
25           get { return price; }
26           set { price = value; }
27       }
28 
29 
30       public HealthCheckItem(string name,int price,string description)
31       {
32           //this
33           this.Name = name;
34           this.Description = description;
35           this.Price = price;
36       }
37     }
38 }
 1   //体检套餐类
 2     //每个套餐包括要检查的项目、套餐名称、总价
 3    public class HealthCheckSet
 4     {
 5        public HealthCheckSet()
 6        {
 7           items=new List<HealthCheckItem>();
 8        }
 9        public HealthCheckSet(string name,List<HealthCheckItem> items )
10        {
11            this.Name = name;
12            this.items = items;
13        }
14 
15        //套餐价格
16        private int price;
17        //检查项目
18        private List<HealthCheckItem> items; 
19        private string name;
20 
21        public string Name
22        {
23            get { return name; }
24            set { name = value; }
25        }
26 
27        public List<HealthCheckItem> Items
28        {
29            get { return items; }
30            set { items = value; }
31        }
32 
33        public int Price
34        {
35            get { return price; }
36            set { price = value; }
37        }
38        //套餐计算方法
39        public  void CalcPrice()
40        {
41            int totalPrice = 0;
42            foreach (HealthCheckItem item in items)
43            {
44                totalPrice += item.Price;
45            }
46            this.price =totalPrice;
47        }
48     }
49 }

原文地址:https://www.cnblogs.com/ruyan886621/p/6572350.html