-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArrow.cs
More file actions
50 lines (45 loc) · 1.24 KB
/
Copy pathArrow.cs
File metadata and controls
50 lines (45 loc) · 1.24 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
namespace Object_Oriented_Programming_In_CSharp {
public enum ArrowHead {
Steel,
Wood,
Obsidian
}
public enum Fletching {
Plastic,
TurkeyFeathers,
GooseFeathers
}
public class Arrow {
public ArrowHead _ArrowHead { get; }
public Fletching _Fletching { get; }
public float _Length { get; }
public float Cost {
get {
return GetArrowheadCost() + GetFletchingCost() + _Length * 0.05f;
}
}
public Arrow(ArrowHead arrowhead, Fletching fletching, float length) {
if (length < 60 || length > 100)
throw new ArgumentException("Length must be between 60 and 100.");
_ArrowHead = arrowhead;
_Fletching = fletching;
_Length = length;
}
private float GetArrowheadCost() {
return _ArrowHead switch {
ArrowHead.Steel => 10,
ArrowHead.Wood => 3,
ArrowHead.Obsidian => 5,
_ => 0
};
}
private float GetFletchingCost() {
return _Fletching switch {
Fletching.Plastic => 10,
Fletching.TurkeyFeathers => 5,
Fletching.GooseFeathers => 3,
_ => 0
};
}
}
}