-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWheel.cs
69 lines (59 loc) · 1.9 KB
/
Wheel.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
using Ex03.GarageLogic.Exceptions;
namespace Ex03.GarageLogic
{
public class Wheel
{
private readonly float r_MaximalWheelAirPressure;
private string m_WheelManufacturerName;
private float m_CurrentWheelAirPressure;
public Wheel(string i_WheelManufacturerName, float i_MaximalWheelAirPressure)
{
m_WheelManufacturerName = i_WheelManufacturerName;
r_MaximalWheelAirPressure = i_MaximalWheelAirPressure;
}
public string WheelName
{
get
{
return m_WheelManufacturerName;
}
set
{
m_WheelManufacturerName = value;
}
}
public float CurrentAirPressure
{
get
{
return m_CurrentWheelAirPressure;
}
set
{
if((value > r_MaximalWheelAirPressure) || (value < 0))
{
throw new ValueOutOfRangeException(r_MaximalWheelAirPressure, 0);
}
m_CurrentWheelAirPressure = value;
}
}
public float MaxAirPressure
{
get
{
return r_MaximalWheelAirPressure;
}
}
public void PumpAirIntoWheel(float i_AmountOfAirToAdd)
{
if (r_MaximalWheelAirPressure >= (i_AmountOfAirToAdd + m_CurrentWheelAirPressure))
{
m_CurrentWheelAirPressure += i_AmountOfAirToAdd;
}
}
public override string ToString()
{
return string.Format("Wheel Manufacturer Name: {0} Max Air Pressure: {1} Current Air Pressure: {2}", WheelName.ToString(), MaxAirPressure.ToString(), this.CurrentAirPressure.ToString());
}
}
}