船台租约
来源:互联网 发布:java this 编辑:程序博客网 时间:2024/06/15 19:24
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication72
{
class AnnualLease : lease
{
private DateTime startDate;//起始日期
public DateTime StartDate
{
get { return startDate; }
set
{
startDate = value;
endDate = startDate.AddDays(period);//终止日期算法与年初不同
}
}
private DateTime endDate;//终止日期
public DateTime EndDate
{
get { return endDate; }
}
private int period;//租用时长
public int Period
{
get { return period; }
set { period = value; }
}
private int berthWidth;//船台宽度
public int BerthWidth
{
get { return berthWidth; }
set
{
berthWidth = value;
switch (berthWidth)
{
case 10: unitPrice = 800; break; //日租单价与年租不同
case 12: unitPrice = 900; break;
case 14: unitPrice = 1100; break;
default: unitPrice = 0; break;
}
}
}
private int unitPrice;//单价
public int UnitPrice
{
get { return unitPrice; }
}
public AnnualLease() { }//构造函数
public AnnualLease(int p, DateTime s, int b) //构造函数
{
Period = p;
StartDate = s;
BerthWidth = b;
}
public double Rent() //计算租金
{
return unitPrice * period;
}
public void Print() //输出
{
Console.WriteLine("---------年租船台租约------------------");
Console.WriteLine("船台规格:{0}", berthWidth);
Console.WriteLine("租用时长:{0}年", period);
Console.WriteLine("租约日期:{0:D}-{1:D}", startDate, endDate);
Console.WriteLine("租金:{0}×{1}={2}", unitPrice, period, Rent());
}
}
class DailyLease : lease
{
private DateTime startDate;//起始日期
public DateTime StartDate
{
get { return startDate; }
set
{
startDate = value;
endDate = startDate.AddDays(period);//终止日期算法与年初不同
}
}
private DateTime endDate;//终止日期
public DateTime EndDate
{
get { return endDate; }
}
private int period;//租用时长
public int Period
{
get { return period; }
set { period = value; }
}
private int berthWidth;//船台宽度
public int BerthWidth
{
get { return berthWidth; }
set
{
berthWidth = value;
switch (berthWidth)
{
case 10: unitPrice = 20; break; //日租单价与年租不同
case 12: unitPrice = 25; break;
case 14: unitPrice = 30; break;
default: unitPrice = 0; break;
}
}
}
private int unitPrice;//单价
public int UnitPrice
{
get { return unitPrice; }
}
public DailyLease() { }//构造函数
public DailyLease(int p, DateTime s, int b) //构造函数
{
Period = p;
StartDate = s;
BerthWidth = b;
}
public double Rent() //计算租金
{
return unitPrice * period;
}
public void Print() //输出
{
Console.WriteLine("---------日租船台租约------------------");
Console.WriteLine("船台规格:{0}", berthWidth);
Console.WriteLine("租用时长:{0}日", period);
Console.WriteLine("租约日期:{0:D}-{1:D}", startDate, endDate);
Console.WriteLine("租金:{0}×{1}={2}", unitPrice, period, Rent());
}
}
class WeekLease : lease
{
private DateTime startDate;//起始日期
public DateTime StartDate
{
get { return startDate; }
set
{
startDate = value;
endDate = startDate.AddDays(period);//终止日期算法与年初不同
}
}
private DateTime endDate;//终止日期
public DateTime EndDate
{
get { return endDate; }
}
private int period;//租用时长
public int Period
{
get { return period; }
set { period = value; }
}
private int berthWidth;//船台宽度
public int BerthWidth
{
get { return berthWidth; }
set
{
berthWidth = value;
switch (berthWidth)
{
case 10: unitPrice = 120; break; //周租单价与年租不同
case 12: unitPrice = 140; break;
case 14: unitPrice = 180; break;
default: unitPrice = 0; break;
}
}
}
private int unitPrice;//单价
public int UnitPrice
{
get { return unitPrice; }
}
public WeekLease() { }//构造函数
public WeekLease(int p, DateTime s, int b) //构造函数
{
Period = p;
StartDate = s;
BerthWidth = b;
}
public double Rent() //计算租金
{
return unitPrice * period;
}
public void Print() //输出
{
Console.WriteLine("---------周租船台租约------------------");
Console.WriteLine("船台规格:{0}", berthWidth);
Console.WriteLine("租用时长:{0}周", period);
Console.WriteLine("租约日期:{0:D}-{1:D}", startDate, endDate);
Console.WriteLine("租金:{0}×{1}={2}", unitPrice, period, Rent());
}
}
class lease
{
static void Main(string[] args)
{
//年租用例
int yp = 1;
DateTime ys = new DateTime(2014, 12, 27);
int yb = 10;
AnnualLease c1 = new AnnualLease(yp, ys, yb);
c1.Print();
//日租用例
int cp = 15;
DateTime cs = new DateTime(2014, 12, 27);
int cb = 14;
DailyLease c2 = new DailyLease(cp, cs, cb);
c2.Print();
//周租用例
int xp = 1;
DateTime xs = new DateTime(2014, 12, 27);
int xb = 12;
WeekLease c3 = new WeekLease(xp, xs, xb);
c3.Print();
Console.ReadKey();
}
}
}
总结:刚用数组与重构、触发器等用的不是很好。
- 船台租约
- 租约
- DHCP租约
- DHCP租约
- 租约机制简介
- DHCP租约的理解
- 租约机制简介
- 租约机制简介
- 异曲同工的租约
- 租约机制简介
- HDFS租约机制
- HDFS租约机制
- HDFS租约机制
- NameNode之租约管理
- [Remoting] 四:生存期租约
- HDFS-租约管理模块儿
- ISC DHCP租约状态转换
- HDFS源码分析(六)-----租约
- Fragments五:与activity通讯
- Comprehensive cover
- Deep Learning(深度学习)Deep Learning的常用模型或者方法(一)
- 第十八周oj平台二:关灯
- linux与linux,linux与windows之间用SSH传输文件
- 船台租约
- Fragments六:处理fragement的生命周期
- 浅谈文字编码和Unicode
- Deep Learning(深度学习)Deep Learning的常用模型或者方法(二)
- WEB与CGI程序的混合编程若干思想
- 条款 23: 必须返回一个对象时不要试图返回一个引用
- 9.IO流
- Spring定时任务的几种实现
- 从自联想神经网络到深度神经网络