-
Notifications
You must be signed in to change notification settings - Fork 0
/
Battery.cs
58 lines (53 loc) · 1.57 KB
/
Battery.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ex03.GarageLogic
{
public struct Battery
{
private float m_PowerLeftInMinutes;
private readonly float m_MaxBatteryInMinutes;
public Battery(float i_MaxBatteryPower)
{
m_MaxBatteryInMinutes = i_MaxBatteryPower;
m_PowerLeftInMinutes = m_MaxBatteryInMinutes;
}
public float CurrentPower
{
get
{
return m_PowerLeftInMinutes;
}
set
{
m_PowerLeftInMinutes = value;
}
}
public float MaxPower
{
get
{
return m_MaxBatteryInMinutes;
}
}
//maybe make two fueling methods with different input paramters? (fuel/power)
public void ChargeVehicleBattery(float i_AmountOfMinutesToAdd)
{
try
{
if (m_MaxBatteryInMinutes >= (i_AmountOfMinutesToAdd + m_PowerLeftInMinutes))
{
m_PowerLeftInMinutes += i_AmountOfMinutesToAdd;
}
}
catch (Exception i_CurrentException)
{
float MaxValue = m_MaxBatteryInMinutes - m_PowerLeftInMinutes;
float MinValue = 0;
throw new ValueOutOfRangeException(i_CurrentException, MaxValue, MinValue);
}
}
}
}