-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
70b1996
commit d9f57d7
Showing
11 changed files
with
707 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Ex03.GarageLogic | ||
{ | ||
public class CarStatus | ||
{ | ||
public enum eCarStatus | ||
{ | ||
UnderRepairs, | ||
Fixed, | ||
PaidFor | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Ex03.GarageLogic | ||
{ | ||
public abstract class Energy | ||
{ | ||
public abstract void FillEnergy(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Ex03.GarageLogic | ||
{ | ||
public class Fuel | ||
{ | ||
public enum eFuelType | ||
{ | ||
eOCTAN98, | ||
eOCTAN96, | ||
eOCTAN95, | ||
eSOLER | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Ex03.GarageLogic | ||
{ | ||
public class FuelTank : Energy | ||
{ | ||
private FuelType.eFuelType m_FuelType; | ||
//private readonly float m_MaxTankCapacity; | ||
//private float m_CurrentAmountOfFuel; | ||
|
||
public FuelTank(FuelType.eFuelType i_FuelType, int i_MaxTankCapacity) | ||
: base(i_MaxTankCapacity) | ||
{ | ||
m_FuelType = i_FuelType; | ||
} | ||
|
||
//public FuelTank(FuelType.eFuelType i_FuelType, int i_MaxTankCapacity) | ||
//{ | ||
// m_FuelType = i_FuelType; | ||
// m_MaxTankCapacity = i_MaxTankCapacity; | ||
// m_CurrentAmountOfFuel = m_MaxTankCapacity; | ||
//} | ||
|
||
//public float MaxTank | ||
//{ | ||
// get | ||
// { | ||
// return m_MaxTankCapacity; | ||
// } | ||
//} | ||
|
||
public FuelType.eFuelType FuelType | ||
{ | ||
get | ||
{ | ||
return m_FuelType; | ||
} | ||
} | ||
|
||
//public float CurrentFuelAmount | ||
//{ | ||
// get | ||
// { | ||
// return m_CurrentAmountOfFuel; | ||
// } | ||
// set | ||
// { | ||
// m_CurrentAmountOfFuel = value; | ||
// } | ||
//} | ||
|
||
//maybe make two fueling methods with different input paramters? (fuel/power) | ||
public void PumpFuelToTank(float i_AmountOfFuelToAdd, FuelType.eFuelType i_PumpFuelType) | ||
{ | ||
if (i_PumpFuelType == m_FuelType) | ||
{ | ||
FillEnergy(i_AmountOfFuelToAdd); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace Ex03.GarageLogic | ||
{ | ||
public class FuelType | ||
{ | ||
public enum eFuelType | ||
{ | ||
Octan98, | ||
Octan96, | ||
Octan95, | ||
Soler | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace Ex03.GarageLogic | ||
{ | ||
public class Garage | ||
{ | ||
private Dictionary<int, Vehicle> m_AllGarageVehicles; | ||
|
||
public Garage() | ||
{ | ||
AllGarageVehicles = new Dictionary<int, Vehicle>(); | ||
} | ||
|
||
public Dictionary<int, Vehicle> AllGarageVehicles | ||
{ | ||
get | ||
{ | ||
return m_AllGarageVehicles; | ||
} | ||
|
||
set | ||
{ | ||
m_AllGarageVehicles = value; | ||
} | ||
} | ||
|
||
public bool IsVehicleInGarageBool(string i_VehicleLicenceNumber) | ||
{ | ||
bool isInDictionary = false; | ||
if (AllGarageVehicles.ContainsKey(i_VehicleLicenceNumber.GetHashCode()) == true) | ||
{ | ||
isInDictionary = true; | ||
} | ||
|
||
return isInDictionary; | ||
} | ||
|
||
public Vehicle GetVehicleFromGarage(string i_VehicleLicenceNumber) | ||
{ | ||
Vehicle currentVehicle; | ||
|
||
if (AllGarageVehicles.TryGetValue(i_VehicleLicenceNumber.GetHashCode(), out currentVehicle) == false) | ||
{ | ||
currentVehicle = null; | ||
} | ||
|
||
return currentVehicle; | ||
} | ||
|
||
public void UpdateStatusOfCar(Vehicle i_CurrentVehicle, string i_VehicleLicenceNumber, VehicleRecord.eVehicleStatus i_UpdatedVehicleStatus) | ||
{ | ||
i_CurrentVehicle.VehicleInGarageRecord.CurrentVehicleStatus = i_UpdatedVehicleStatus; | ||
} | ||
|
||
public void CheckIfStringIsEmpty(string i_StringToBeAnalayzed) | ||
{ | ||
if(i_StringToBeAnalayzed.Equals(string.Empty)) | ||
{ | ||
throw new ArgumentException("String cannot be left empty!"); | ||
} | ||
} | ||
|
||
public void CheckIfStringIsNumber(string i_StringToBeAnalayzed) | ||
{ | ||
bool isNumber = true; | ||
for (int i = 0; (i < i_StringToBeAnalayzed.Length) && (isNumber != false); i++) | ||
{ | ||
if (!char.IsDigit(i_StringToBeAnalayzed[i])) | ||
{ | ||
throw new ArgumentException("Value must only be digits!"); | ||
} | ||
} | ||
} | ||
|
||
public void PhoneIsTenChars(string i_PhoneNumber) | ||
{ | ||
if(i_PhoneNumber.Length != 10) | ||
{ | ||
throw new ArgumentException("Phone number must be 10 characters!"); | ||
} | ||
} | ||
|
||
public void CheckIfStringIsLetters(string stringToBeAnalayzed) | ||
{ | ||
bool isLetters = false; | ||
for (int i = 0; (i < stringToBeAnalayzed.Length) && (isLetters != true); i++) | ||
{ | ||
if (!char.IsLetter(stringToBeAnalayzed[i])) | ||
{ | ||
throw new ArgumentException("Value mustn't be numbers!"); | ||
} | ||
} | ||
} | ||
|
||
public void PumpAllWheelsToMax(string i_VehicleLicenceNumber) | ||
{ | ||
AllGarageVehicles.TryGetValue(i_VehicleLicenceNumber.GetHashCode(), out Vehicle o_CurrentVehicle); | ||
for (int i = 0; i < o_CurrentVehicle.WheelBoltedToVehicle.Count; i++) | ||
{ | ||
float MaxAmountOfAirToAdd = o_CurrentVehicle.WheelBoltedToVehicle[i].MaxAirPressure - o_CurrentVehicle.WheelBoltedToVehicle[i].CurrentAirPressure; | ||
o_CurrentVehicle.WheelBoltedToVehicle[i].PumpAirIntoWheel(MaxAmountOfAirToAdd); | ||
} | ||
} | ||
|
||
public void PumpFuelToVehicle(string i_VehicleLicenceNumber, int i_SelectedFuelType, float i_AmountOfPropulsionToAdd) | ||
{ | ||
FuelType.eFuelType currentPumpedFuel; | ||
AllGarageVehicles.TryGetValue(i_VehicleLicenceNumber.GetHashCode(), out Vehicle o_CurrentVehicle); | ||
switch (i_SelectedFuelType) | ||
{ | ||
case 1: | ||
currentPumpedFuel = FuelType.eFuelType.Octan98; | ||
break; | ||
case 2: | ||
currentPumpedFuel = FuelType.eFuelType.Octan96; | ||
break; | ||
case 3: | ||
currentPumpedFuel = FuelType.eFuelType.Octan95; | ||
break; | ||
case 4: | ||
currentPumpedFuel = FuelType.eFuelType.Soler; | ||
break; | ||
default: | ||
currentPumpedFuel = 0; | ||
break; | ||
} | ||
|
||
FuelTank tankToBeFueld = o_CurrentVehicle.Propulsion as FuelTank; | ||
if (currentPumpedFuel == tankToBeFueld.FuelType) | ||
{ | ||
tankToBeFueld.PumpFuelToTank(i_AmountOfPropulsionToAdd, currentPumpedFuel); | ||
o_CurrentVehicle.UpdateVehicleCurrentPropulsion(); | ||
} | ||
else | ||
{ | ||
throw new ArgumentException("Fuel type does not match! Didn't fuel vehicle..."); | ||
} | ||
} | ||
|
||
public void ChargeVehicle(string i_VehicleLicenceNumber, float i_AmountOfPropulsionToAdd) | ||
{ | ||
AllGarageVehicles.TryGetValue(i_VehicleLicenceNumber.GetHashCode(), out Vehicle o_CurrentVehicle); | ||
(o_CurrentVehicle.Propulsion as Battery).ChargeBattery(i_AmountOfPropulsionToAdd); | ||
o_CurrentVehicle.UpdateVehicleCurrentPropulsion(); | ||
} | ||
|
||
public void RecordAttachment(Vehicle i_NewVehicle, VehicleRecord i_NewVehicleRecord) | ||
{ | ||
i_NewVehicle.VehicleInGarageRecord = i_NewVehicleRecord; | ||
} | ||
|
||
public Vehicle InputVehicleRecord(int i_CarType, string i_VehicleLicenceNumber, string i_VehicleModelName, string i_WheelManufacturerName) | ||
{ | ||
Vehicle currentVehicle = VehicleTypes.CreateVehicle(i_CarType, i_VehicleLicenceNumber, i_VehicleModelName, i_WheelManufacturerName); | ||
return currentVehicle; | ||
} | ||
} | ||
} |
Oops, something went wrong.