-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCheckout.cs
More file actions
74 lines (67 loc) · 1.77 KB
/
Checkout.cs
File metadata and controls
74 lines (67 loc) · 1.77 KB
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Collections;
public class Checkout{
private static Inventory inventory = null;
ArrayList inv = new ArrayList();
var myList = new List<KeyValuePair<string, Item>>();
private ItemType type;
private string itemName;
private int itemCode;
private DateTime expirydate;
private int checkoutID;
private DateTime rentaldate;
// return rented item
public void returnRentedItem(String code, double qty){
Checkout new = new Checkout();
new.returnItem(code, qty);
}
//Set a unique ID for Checkout
public void setCheckoutID(int id)
{
checkoutID = id;
}
//Get the unique checkout id
public int getCheckoutID()
{
return checkoutID;
}
// Create a new checkout, get student's complete cart, and checkout
// everything. Then add the checkout to the transaction history
public void checkoutItems(){
Checkout co = new Checkout();
new.getCart(cart);
new.checkoutAll();
transactionHistory.add(new);
}
}
public class RegularOrder : OrderBase
{
public override double CalculateTotalOrderPrice()
{
Console.WriteLine("Calculating the total price of a regular order");
return products.Sum(x => x.Price);
}
}
public class Preorder : OrderBase
{
public override double CalculateTotalOrderPrice()
{
Console.WriteLine("Calculating the total price of a preorder.");
return products.Sum(x => x.Price) * 0.9;
}
}
class New
{
static void Main(string[] args)
{
var regularOrder = new RegularOrder();
Console.WriteLine(regularOrder.CalculateTotalOrderPrice());
Console.WriteLine();
var preOrder = new PreOrder();
Console.WriteLine(preOrder.CalculateTotalOrderPrice());
Console.WriteLine();
}
}