这篇文章主要为大家详细介绍了C#实现汽车租赁系统的具体实现代码,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
最近学习了继承,多态,集合,设计模式,有一个汽车租凭系统,给大家分享一下:
我们首先来看看我们这个系统的效果
1.做一个项目,我们首先对项目进行分析
根据我们最近学的知识,我们可以看出继承,多态,集合,设计模式,我们都能用到
我们把所需要的类和简单模式中的“简单工厂”的工厂准备好
类图:
01.车辆类(父类)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace 汽车租赁系统
{
// 车辆类 父类
public abstract class Vehicle
{
//属性
//车牌号
public string LicenseNo { get; set; }
//车名
public string Name { get; set; }
//颜色
public string Color { get; set; }
//使用时间
public int RentDate { get; set; }
//使用人
public string RentUser { get; set; }
//日租金
public double DailyRent { get; set; }
//还车日期
public int ReturnDate { get; set; }
public Vehicle() { }
//构造
public Vehicle(string liceseno,string name,string color,int rentdate,double dailyrent)
{
this.Color = color;
this.DailyRent = dailyrent;
this.LicenseNo = liceseno;
this.Name = name;
this.RentDate = rentdate;
}
//计算价格的虚方法
public abstract double GetNum();
}
}














