-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFood.cs
More file actions
89 lines (72 loc) · 2.02 KB
/
Food.cs
File metadata and controls
89 lines (72 loc) · 2.02 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
public abstract class Food
{
protected int _foodScore;
public int FoodScore => _foodScore;
public void SetFoodScore(int m_score)
{
this._foodScore = m_score;
}
}
public class FoodElement : Food
{
private char _foodChar;
private int _colorNumber;
public char FoodChar => _foodChar;
public int ColorNumber => _colorNumber;
public FoodElement(char m_char, int m_foodScore)
{
this._foodChar = m_char;
this._foodScore = m_foodScore;
}
public void SetColor(int m_colorNumber)
{
this._colorNumber = m_colorNumber;
}
/// <summary>
/// ( FE1 = FE2.Copy() )
/// FE1으로 얕은복사 진행
/// </summary>
public FoodElement Copy()
{
FoodElement copy = new FoodElement(this._foodChar,_foodScore);
copy.SetColor(this._colorNumber);
return copy;
}
}
public class Burger : Food
{
private List<FoodElement> _burgerStack = new List<FoodElement>();
public int Count => _burgerStack.Count;
private int _price;
public int Price => _price;
public Burger(int m_price)
{
this._price = m_price;
}
public FoodElement this[int idx] => _burgerStack[idx];
/// <summary>
/// 재료번호와 현재 층에 맞는 계산된 Score를 반환합니다.
/// </summary>
public static int CalculateElementScore(FoodElement m_element,int m_stackLine)
{
return (m_element.FoodScore / m_stackLine) + 1;
}
/// <summary>
/// 버거에 음식재료를 추가합니다.
/// </summary>
public void AddStack(FoodElement m_food)
{
//_foodScore += m_food.FoodScore;
_burgerStack.Add(m_food);
//_foodScore += (m_food.FoodScore / _burgerStack.Count)+1;
_foodScore += CalculateElementScore(m_food, _burgerStack.Count);
}
/// <summary>
/// 버거를 마무리합니다.
/// </summary>
public void CloseStack()
{
AddStack(_burgerStack.First());
_foodScore += _burgerStack.Count;
}
}