From e2d8f45cb22ad9610d654a242df17758cca67ff7 Mon Sep 17 00:00:00 2001 From: Dan <daniel2.lorych@live.uwe.ac.uk> Date: Wed, 27 Apr 2022 19:38:46 +0100 Subject: [PATCH] Add Battery class --- Helios/Source/Battery.cs | 42 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 Helios/Source/Battery.cs diff --git a/Helios/Source/Battery.cs b/Helios/Source/Battery.cs new file mode 100644 index 0000000..833d49e --- /dev/null +++ b/Helios/Source/Battery.cs @@ -0,0 +1,42 @@ +using System; +namespace Helios.Source +{ + public class Battery + { + public int Capacity { get; set; } + public int Voltage { get; set; } + public double Charge { get; private set; } + public double DepthOfDischarge { get; private set; } + + public Battery() { } + + public Battery(int capacity, int voltage) + { + this.Capacity = capacity; + this.Voltage = voltage; + } + + public double GetCharge(double powerBalence) + { + double charge; + + charge = powerBalence / this.Voltage; + + this.Charge = charge; + + return charge; + } + + public double GetDepthOfDischarge() + { + double depthOfDischarge; + + depthOfDischarge = (1 - (this.Charge / this.Capacity)) * 100; + + this.DepthOfDischarge = depthOfDischarge; + + return depthOfDischarge; + } + } +} + -- GitLab