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
public class Startup | |
{ | |
public void ConfigureServices(IServiceCollection services) | |
{ | |
services.AddMvc(); | |
//一般員工薪資計算 | |
//services.AddTransient<HR.ISalaryFormula, HR.SalaryFormula>(); | |
//換一個公式(替換成請假不扣薪公式) | |
services.AddTransient<HR.ISalaryFormula, HR.BossSalaryFormula>(); | |
} |
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
public class Startup | |
{ | |
public void ConfigureServices(IServiceCollection services) | |
{ | |
services.AddMvc(); | |
//一般員工薪資計算 | |
services.AddTransient<HR.ISalaryFormula, HR.SalaryFormula>(); | |
//替換成請假不扣薪公式 | |
//services.AddTransient<HR.ISalaryFormula, HR.BossSalaryFormula>(); | |
} |
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
public class SalaryCalculatorModel : PageModel | |
{ | |
private HR.ISalaryFormula _SalaryFormula; | |
public SalaryCalculatorModel(HR.ISalaryFormula SalaryFormula) | |
{ | |
_SalaryFormula = SalaryFormula; | |
} | |
public float Salary { get; set; } | |
public ActionResult OnGet() |
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
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
//一般員工 SalaryFormula | |
SalaryCalculator SC = new SalaryCalculator(new SalaryFormula()); | |
//注意參數完全相同 | |
float amount = SC.Calculate(8 * 19, 200, 8); | |
Console.Write("\nSalaryFormula--->amount:" + amount); |
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
namespace ConsoleApp2 | |
{ | |
/// <summary> | |
/// 計算薪資的類別 | |
/// </summary> | |
class SalaryCalculator | |
{ | |
/// <summary> | |
/// 計算薪資的公式物件 | |
/// </summary> |
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
namespace ConsoleApp1 | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
//使用薪資計算器 SalaryCalculator,引用基本公式 SalaryFormula | |
SalaryCalculator SC = new SalaryCalculator(new SalaryFormula()); | |
//工時 , 時薪, 請假天數 | |
float amount = SC.Calculate(8 * 19, 200, 8); |
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
namespace ConsoleApp1 | |
{ | |
/// <summary> | |
/// 計算薪資的類別 | |
/// </summary> | |
class SalaryCalculator | |
{ | |
/// <summary> | |
/// 計算薪資的公式物件 | |
/// </summary> |
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
void fun | |
{ | |
//使用薪資計算器 SalaryCalculator,引用基本公式 SalaryFormula | |
SalaryCalculator SC = new SalaryCalculator(new SalaryFormula()); | |
//工時 , 時薪, 請假天數 | |
float amount = SC.Calculate(8 * 19, 200, 8); | |
Console.Write("amount:" + amount); | |
Console.ReadKey(); | |
} |