实验4 4.1

1.mot

package exam4;

public class Motorvecle {
    private String no;
    private String brand;
    int a;
    int day;
    public Motorvecle(String no,String brand) {
        this.no = no;
        this.brand = brand;
    }
    public void setNo(String no) {
        this.no = no;
    }
    public void setBrand(String brand) {
        this.brand = brand;
    }
    public String getNo() {
        return no;
    }
    public String getBrand() {
        return brand;
    }
    public void carRent(int days) {
        
        System.out.println(days*600);    }
}
2.car

package exam4;

public class Car extends Motorvecle{
    private String type;
    int b;
    int in;
    public Car(String no,String brand,String type){
        super(no,brand);
        this.type = type;
    }
    public String getType() {
        return type;
    }
    public void carRent(int days) {
        System.out.println(days*500);
    }
}
3.bus

package exam4;

public class Bus extends Motorvecle{
    private int seatCount;
    public Bus(String no,String brand,int seatCount){
        super(no,brand);
        this.seatCount = seatCount;
    }
    public void carRent(int days) {
        if(seatCount >= 16) {
            System.out.println(days*1500);
        }else {
            System.out.println(800*days);
        }
        
    }
    
}
4.test

package exam4;

import java.util.Scanner;

public class Test {

    public static void main(String[] args) {
        Car c1 = new Car("别克商务仓GL8","","");
        
        System.out.println("请输入要租赁的天数:");
        Scanner in = new Scanner(System.in);
        int days = in.nextInt();
        System.out.println("请输入要租赁的汽车类型:(1.轿车2.客车)");
        int t = in.nextInt();
        if(t == 1) {
            System.out.println("请输入轿车型号:(1.商务仓GL8 2.林荫大道)");
            int t2 = in.nextInt();
        if(t2 == 1) {
            System.out.println("请输入要租赁的汽车品牌:");
        }
        
        }
        if(t == 2) {
            System.out.println("请输入要租赁的客车品牌:(1.金杯 2.金龙)");
        }
        
        
        
        
        System.out.println("请输入要租赁的天数:");
        

    }

}
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

推向黄昏

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值