Permalink
Browse files

Extract `Footer()`

- Extract method `Footer()` with better string format
- Rename `Initialize()` to `ClearTotals()`
  • Loading branch information...
rdeneau committed Aug 21, 2018
1 parent 4718dd6 commit 124742ba65dc20b2aa90a0f7d4d6d35b7d87a896
Showing with 10 additions and 6 deletions.
  1. +10 −6 2_Uncle_Bob_Full/Soat.CleanCode.VideoStore.UncleBobFull/Statement.cs
@@ -23,16 +23,20 @@ public void AddRental(Rental rental)

public string Generate()
{
Initialize();
ClearTotals();
var statementText = Header();
statementText += RentalLines();

statementText += "You owed " + TotalAmount.ToString("0.0", CultureInfo.InvariantCulture) + "\n";
statementText += "You earned " + FrequentRenterPoints.ToString() + " frequent renter points\n";

statementText += Footer();
return statementText;
}

private string Footer()
{
var totalAmount = TotalAmount.ToString("0.0", CultureInfo.InvariantCulture);
return $"You owed {totalAmount}\n" +
$"You earned {FrequentRenterPoints} frequent renter points\n";
}

private string RentalLines()
{
var rentalLines = "";
@@ -84,7 +88,7 @@ private string Header()
return $"Rental Record for {CustomerName}\n";
}

private void Initialize()
private void ClearTotals()
{
FrequentRenterPoints = 0;
TotalAmount = 0m;

0 comments on commit 124742b

Please sign in to comment.