-
Notifications
You must be signed in to change notification settings - Fork 0
/
Drink.cs
80 lines (64 loc) · 2.06 KB
/
Drink.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
using System;
using System.Collections.Generic;
using System.Text;
namespace PizzaOrderingSystem
{
public class Drink:OrderItem
{
private static readonly string[] drinkTypeChoice= {"Soft Drink","Juice"};
public string[] DrinkTypeChoice
{
get
{
return drinkTypeChoice;
}
}
private static readonly double[] drinkTypePrice = { 3.50, 4.50 };
private static readonly double[] drinkSizePrice = { 0.80, 1.00, 1.20 };
public Drink()
: base()
{
}
public Drink(string size, string type, int quantity)
:base(size,type,quantity)
{
}
public override string ObtainSize(int choice)
{
switch (choice)
{
case 1:
return SizeChoice[0]; //Small
case 2:
return SizeChoice[1]; //Medium
case 3:
return SizeChoice[2]; //Large
default:
throw new ArgumentOutOfRangeException("", "Value should be ranged from '1' to '3' only!");
}
}
public override string ObtainType(int choice)
{
switch (choice)
{
case 1:
return DrinkTypeChoice[0]; //Soft Drink
case 2:
return DrinkTypeChoice[1]; //Juice
default:
throw new ArgumentOutOfRangeException("", "Value should be ranged from '1' to '2' only!");
}
}
public override double ComputePricePerUnit()
{
double typePrice = 0, sizePrice = 0;
for(int i=0;i<drinkTypeChoice.Length;i++)
if (Type == drinkTypeChoice[i])
typePrice = drinkTypePrice[i];
for(int i=0;i<SizeChoice.Length;i++)
if (Size == SizeChoice[i])
sizePrice = drinkSizePrice[i];
return typePrice * sizePrice;
}
}
}