using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SimpleFactory.App.IFactroy
{
public interface Ishop
{
double Getrent(int days, double dayprice, double performance);
}
}
using SimpleFactory.App.IFactroy;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SimpleFactory.App.product
{
//A类型的商店的创建
public class Ashop:Ishop
{
/// <summary>
/// /// A类型商店租金额,天数*单价+绩效*0.005
/// </summary>
/// <param name="days">天数</param>
/// <param name="dayprice">每天单价</param>
/// <param name="performance">日平均绩效</param>
/// <returns></returns>
public double Getrent(int days, double dayprice, double performance)
{
Console.WriteLine("A商店的租金算法");
return days * dayprice + performance * 0.01;
}
}
}
using SimpleFactory.App.IFactroy;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SimpleFactory.App.product
{
/// <summary>
/// B类型的商店的创建
/// </summary>
public class Bshop:Ishop
{
/// <summary>
/// B类型商店的租金=月份*(每月价格+performance*0.001)
/// </summary>
/// <param name="month">月数</param>
/// <param name="monthprice">月单价</param>
/// <param name="performance">月平均绩效</param>
/// <returns></returns>
public double Getrent(int month, double monthprice, double performance)
{
Console.WriteLine("B商店的租金算法");
return month * (monthprice + performance * 0.001);
}
}
}
using SimpleFactory.App.IFactroy;
using SimpleFactory.App.product;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SimpleFactory.App.factoryMethod
{
public class factorymethod
{
public Ishop CreateShow(string show)
{
switch (show.Trim().ToLower())
{
case"ashop":
return new Ashop();
case "bshop":
return new Ashop();
default:
throw new Exception("该商店不存在");
}
}
}
}
using SimpleFactory.App.factoryMethod;
using SimpleFactory.App.IFactroy;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SimpleFactory.App
{
class Program
{
static void Main(string[] args)
{
Ishop As;
factorymethod afm = new factorymethod();
As = afm.CreateShow("ashop"); //a 类型的某商店
double total = As.Getrent(30, 300, 2000); //30 天/100元 日平均绩效为2000
Console.WriteLine("该A类型商店的租金为:" + total);
Console.WriteLine("=============");
Ishop Bs;
factorymethod bfm = new factorymethod();
Bs = bfm.CreateShow("bshop"); //b 类型的某商店
total = Bs.Getrent(3, 3000, 60000); //3 月/4000元 月平均绩效为60000
Console.WriteLine("该B类型商店的租金为:" + total);
Console.ReadKey();
}
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有