Professional Documents
Culture Documents
PT1-ReTest (PS11-12 Hoh Jungi)
PT1-ReTest (PS11-12 Hoh Jungi)
1 PT1-ReTest
2
3
4 Screen-Capture(s)
5
6
7
8
9 Filename: Program.cs
10
11 using System;
12 using System.Collections.Generic;
1 using System.Linq;
2 using System.Text;
3 using System.Threading.Tasks;
4
5 namespace PT1ReTest_Hoh_Jungi
6 {
7 class Shop
8 {
9 private string strName;
10 protected int intQuantity;
11 protected float fltPrice;
12 private static int intTotalQuantity;
13
14 public Shop(string name, int quantity, float price)
15 {
16 strName = name;
17 intQuantity = quantity;
18 fltPrice = price;
19 intTotalQuantity += intQuantity;
20 }
21
22 public string Name
23 {
24 get { return strName; }
25 }
26
27 public static int TotalQuantity
28 {
29 get { return intTotalQuantity; }
30 }
31
32 public virtual float GetCost()
33 {
34 return intQuantity * fltPrice;
35 }
36 }
37
38 class Order:Shop
39 {
40 private int intDiscount;
41
42 public Order(int d, string n, int q, float p):base(n, q, p)
43 {
44 intDiscount = d;
45 }
46 public override float GetCost()
47 {
48 return base.GetCost()*(100f-intDiscount)/100f;
49 }
50 public string CheckBudget(float budget)
51 {
52 if (budget < GetCost())
53 {
54 return "Exceeded";
55 }
56 else
57 {
58 return "OK";
59 }
60 }
61 }
62 internal class Program
63 {
1 }
2
3 Console.WriteLine("==============================");
4 Console.WriteLine("Total order quantity: {0}", Order.TotalQuantity);
5
6 Console.ReadKey();
7 }
8 }
9 }
10
11