This repository has been archived by the owner on Oct 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
/
Program.cs
executable file
·63 lines (55 loc) · 1.99 KB
/
Program.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
using System;
using Bangazon.Customers;
using Bangazon.Orders;
using Bangazon.Payments;
namespace Bangazon
{
public class Program
{
public static void Main(string[] args)
{
// Create a customer and grab first/last name from first argument
Customer firstCustomer = new Customer();
firstCustomer.firstName = args[0].Split(new Char[] { ' ' })[0];
firstCustomer.lastName = args[0].Split(new Char[] { ' ' })[1];
firstCustomer.greet();
// Create an order and add product from argument list
Order firstOrder = new Order();
for(int i = 1; i < args.Length - 1; i++)
{
firstOrder.addProduct(args[i]);
}
Console.WriteLine(firstOrder.listProducts());
// Create a payment
Payment payment = null;
string mainEmailAddress = "[email protected]";
// Depending on the value of the last argument, assign
// the payment variable to the correct derived class
switch (args[args.Length - 1])
{
case "credit":
payment = new CreditCard(firstOrder)
{
bankName = "Amex",
accountNumber = "948587245092"
};
break;
case "paypal":
payment = new Paypal(firstOrder)
{
email = mainEmailAddress,
password = "1234512345"
};
break;
default:
break;
}
// Simplistic operation to calculate total order cost
payment.amount = firstOrder.products.Count * 9.99;
// Process the payment
Console.WriteLine(payment.process());
// Send confirmation email
payment.confirm(mainEmailAddress);
}
}
}