-
Notifications
You must be signed in to change notification settings - Fork 0
/
Order.cs
114 lines (105 loc) · 2.95 KB
/
Order.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _6270PersonalAttempt
{
/// <summary>
/// Processing totals here..
/// </summary>
class Order
{
public List<PhotoLineItem> lines;
private List<Discount> discounts;
private List<Fee> fees;
public Order()
{
lines = new List<PhotoLineItem>();
discounts = new List<Discount>();
fees = new List<Fee>();
}
public List<PhotoLineItem> Lines
{
get { return lines; }
}
public List<Discount> Discount
{
get { return discounts; }
}
public List<Fee> Fee
{
get { return fees; }
}
//tried using :base() but it still gave an error so i took the lazy (bad) way out and copied the constructor.
public Order(PhotoLineItem line, Discount discount)
{
lines = new List<PhotoLineItem>();
discounts = new List<Discount>();
//fees = new List<Fee>();
lines.Add(line);
discounts.Add(discount);
// fees.Add(fee);
}
public void addLine(PhotoLineItem item)
{
if (item.LineRate <= 0)
{
throw new System.ArgumentException("Parameter not entered", "lineRate");
}
lines.Add(item);
}
public void addDiscount(Discount discount)
{
if (discount.getTotalDiscount() > 0)
{
discounts.Add(discount);
}
}
public void addFee(Fee fee)
{
if (fee.Amount > 0)
fees.Add(fee);
}
public decimal getTotal()
{
decimal total = 0;
foreach (var line in lines)
{
total += line.Quantity * line.LineRate;
}
// /foreach (var fee in fees)
//{
// total += fee.Amount;
// }
if (total <= 35)
{
foreach (var discount in discounts)
{
total += discount.getTotalDiscount();
}
}
return total;
}
public decimal getTotal2()
{
decimal total = 0;
foreach (var line in lines)
{
total += line.Quantity * line.LineRate2;
}
// /foreach (var fee in fees)
//{
// total += fee.Amount;
// }
if (total <= 35)
{
foreach (var discount in discounts)
{
total += discount.getTotalDiscount();
}
}
return total;
}
}
}