ACCP 7.0 C#项目 汽车租赁系统

本文介绍了一个使用C#编程的汽车租赁系统,包括一个抽象基类`Vehicle`,两个子类`Truck`和`Car`,分别代表卡车和轿车。系统支持车辆的价格计算,租车和还车功能,以及租车信息的展示。通过泛型集合管理可出租和已出租的车辆,并使用ListView控件进行可视化展示。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 
//先 写出 1个 父类 2个子类
 /// 
    /// 父类
    /// 
    public abstract  class Vehicle
    {
        //颜色
        public  string Color{get;set;}

        //日租金
        public  double DailyRent { get; set; }

        //车牌号
        public  string LicenseNO { get; set; }

        //车名
        public  string Name { get; set; }

        //租车日期
        public  int RentDate {get; set; }

        //租车人
        public  string RentUser { get; set; }

        //使用时间
        public  int YearsOFService { get; set; }

        /// 计算价格的方法
        public abstract double CalcPrice();

        public Vehicle() { }

        public Vehicle(string color, double dailyrent, string licenseno, string name, int rentdate, string rentuser, int yearsofservice)
        {
            this.Color = color;
            this.DailyRent = dailyrent;
            this.LicenseNO = licenseno;
            this.Name = name;
            this.RentDate = rentdate;
            this.RentUser = rentuser;
            this.YearsOFService = yearsofservice;
        }


    }
 
//继承 为多态做准备 卡车类
   class Truck : Vehicle
    {
        //载重
        public int Load { get; set; }

        public Truck() { }

        public Truck(string color, double dailyrent, string licenseno, string name, int rentdate, string rentuser, int yearsofservice, int load)
            : base(color, dailyrent, licenseno, name, rentdate, rentuser, yearsofservice)
        {
            this.Load = load;
        }

        /// 
        /// 卡车费用计算方法
        /// 30天以内(含30)按日租金计算
        /// 30天以上超出部分:每天,每吨(载重量)增加日租金10%
        /// 
        public override double CalcPrice()
        {
            double totalPrice = 0;
            double basicPrice = this.RentDate * this.DailyRent;
            if (this.RentDate <= 30)
            {
                totalPrice = basicPrice;
            }
            else
            {
                //30天以上超出部分:每天,每吨(载重量)增加日租金10%
                totalPrice = basicPrice + (this.RentDate - 30) * this.Load * this.DailyRent
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值