-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Tax calculation system on Total food price based on the type of…
… restraunt by using strategy pattern
- Loading branch information
Showing
45 changed files
with
181 additions
and
216 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
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,7 @@ | ||
namespace FoodDeliveryApp.FoodCostTaxCalculation | ||
{ | ||
public interface ITaxCalculator | ||
{ | ||
double CalculateTax(double price, double tax, bool imported); | ||
} | ||
} |
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,20 @@ | ||
using FoodDeliveryApp.Utils; | ||
|
||
namespace FoodDeliveryApp.FoodCostTaxCalculation | ||
{ | ||
public class OneStarTaxCalculator : ITaxCalculator | ||
{ | ||
public double CalculateTax(double price, double localTax, bool imported) | ||
{ | ||
double tax = price * localTax; | ||
|
||
if (imported) | ||
tax += (price * 0.5); | ||
|
||
//rounds off to nearest 0.05; | ||
tax = TaxUtil.RoundOff(tax); | ||
|
||
return tax; | ||
} | ||
} | ||
} |
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,17 @@ | ||
namespace FoodDeliveryApp.FoodCostTaxCalculation | ||
{ | ||
public class TaxCalculationContext | ||
{ | ||
private readonly ITaxCalculator taxCalculator; | ||
|
||
public TaxCalculationContext(ITaxCalculator taxCalculator) | ||
{ | ||
this.taxCalculator = taxCalculator; | ||
} | ||
|
||
public double GetCalculatedTax(double price, double tax, bool imported) | ||
{ | ||
return taxCalculator.CalculateTax(price, tax, imported); | ||
} | ||
} | ||
} |
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,20 @@ | ||
using FoodDeliveryApp.Utils; | ||
|
||
namespace FoodDeliveryApp.FoodCostTaxCalculation | ||
{ | ||
public class ThreeStarTaxCalculator | ||
{ | ||
public double CalculateTax(double price, double localTax, bool imported) | ||
{ | ||
double tax = price * localTax; | ||
|
||
if (imported) | ||
tax += (price * 2.5); | ||
|
||
//rounds off to nearest 0.05; | ||
tax = TaxUtil.RoundOff(tax); | ||
|
||
return tax; | ||
} | ||
} | ||
} |
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,20 @@ | ||
using FoodDeliveryApp.Utils; | ||
|
||
namespace FoodDeliveryApp.FoodCostTaxCalculation | ||
{ | ||
public class TwoStarTaxCalculator : ITaxCalculator | ||
{ | ||
public double CalculateTax(double price, double localTax, bool imported) | ||
{ | ||
double tax = price * localTax; | ||
|
||
if (imported) | ||
tax += (price * 1.5); | ||
|
||
//rounds off to nearest 0.05; | ||
tax = TaxUtil.RoundOff(tax); | ||
|
||
return tax; | ||
} | ||
} | ||
} |
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
Binary file not shown.
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 |
---|---|---|
@@ -1,39 +1,13 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace FoodDeliveryApp.FoodDeliveryAppModel | ||
namespace FoodDeliveryApp.FoodDeliveryAppModel | ||
{ | ||
public class RestaurantModel | ||
{ | ||
private string restaurantId; | ||
public string RestaurantId | ||
{ | ||
get { return restaurantId; } | ||
set { restaurantId = value; } | ||
} | ||
public string RestaurantId { get; set; } | ||
|
||
private string name; | ||
public string Name | ||
{ | ||
get { return name; } | ||
set { name = value; } | ||
} | ||
public string Name { get; set; } | ||
|
||
private string address; | ||
public string Address | ||
{ | ||
get { return address; } | ||
set { address = value; } | ||
} | ||
public string Address { get; set; } | ||
|
||
private int rating; | ||
public int Rating | ||
{ | ||
get { return rating; } | ||
set { rating = value; } | ||
} | ||
public int Rating { get; set; } | ||
} | ||
} |
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
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
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
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
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
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
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
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
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
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
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
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
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
Oops, something went wrong.