-
Notifications
You must be signed in to change notification settings - Fork 0
/
Pedido.cs
55 lines (41 loc) · 1.12 KB
/
Pedido.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtividadeAvaliativa
{
internal class Pedido
{
public static Int64 Serial { get; private set; }
public Int64 NotaFiscal { get; set; }
public List<Item> Items { get; set; }
static Pedido()
{
Serial = Convert.ToInt64(DateTime.Now.Year.ToString().Substring(2)) * 1000000;
}
public Pedido()
{
Items = new List<Item>();
NotaFiscal = Serial;
Serial += 1;
}
public void AdicionarItem(Item item)
{
Items.Add(item);
}
public Decimal CalcularTotal()
{
Decimal total = 0;
foreach (Item item in Items)
{
total += item.CalcularTotal();
}
return total;
}
public override string ToString()
{
return $"> {NotaFiscal} R${CalcularTotal()}";
}
}
}