-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVehicle.cs
67 lines (59 loc) · 1.96 KB
/
Vehicle.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Powerline
{
public abstract class Vehicle
{
protected byte _AverageFuelConsumptionPer100; //per 100km
protected byte _FuelTankCapacity, _CurrentSpeed;
protected byte _FuelLeftPercentage;
public Vehicle()
{
_AverageFuelConsumptionPer100 = 1; // default value
_FuelTankCapacity = 1; // default value
}
public Vehicle( byte AverageFuelConsumptionPer100, byte FuelTankCapacity,
byte CurrentSpeed, byte FuelLeftPercentage)
{
_AverageFuelConsumptionPer100 = AverageFuelConsumptionPer100;
_FuelTankCapacity = FuelTankCapacity;
_CurrentSpeed = CurrentSpeed;
_FuelLeftPercentage = FuelLeftPercentage;
}
public byte AverageFuelConsumptionPer100
{
get { return _AverageFuelConsumptionPer100; }
set { _AverageFuelConsumptionPer100 = value; }
}
public byte FuelTankCapacity
{
get { return _FuelTankCapacity; }
set { _FuelTankCapacity = value; }
}
public byte CurrentSpeed
{
get { return _CurrentSpeed; }
set { _CurrentSpeed = value; }
}
public byte FuelLeftPercentage
{
get { return _FuelLeftPercentage; }
set { _FuelLeftPercentage = value; }
}
virtual public float DistanceLeft()
{
float _DistanceLeft;
_DistanceLeft = _FuelTankCapacity * _FuelLeftPercentage / _AverageFuelConsumptionPer100;
return _DistanceLeft;
}
virtual public float MinutesToFullstop()
{
float _MinutesToFullstop;
_MinutesToFullstop = DistanceLeft() / _CurrentSpeed* 60;
return _MinutesToFullstop;
}
}
}