继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续
感谢您的支持,我会继续努力的
赞赏金额会直接到老师账户
将二维码发送给自己后长按识别
微信支付
支付宝支付

Java第二季租车系统的项目程序

飞向天空的鱼
关注TA
已关注
手记 2
粉丝 0
获赞 0

//父类
package com.xianmu;

public abstract class Car {
public Car()
{
System.out.println("车型有");
System.out.println("皮卡车1,皮卡车2,客车1,客车2");
}
public int number;
public abstract void price(int number);
public abstract void chexing();
public abstract void zaihuo(int number);
public abstract void zairen(int number);

}


//子类客车1
package com.xianmu;

public class kache2 extends Car {
public int price=111;
public String carname="卡车1";
public int huoliang=11;
public int renliang=1;
public int number;
@Override
public void price(int number) {
// TODO Auto-generated method stub
System.out.println("总金额为"+(number*price));
}

@Override
public void chexing() {
    // TODO Auto-generated method stub
    System.out.println(carname);
}

@Override
public void zaihuo(int number) {
    // TODO Auto-generated method stub
    System.out.println("总载货量为"+(number*huoliang));
}

@Override
public void zairen(int number) {
    // TODO Auto-generated method stub
    System.out.println("总载人量为"+(number*renliang));
}

}


//子类卡车1
package com.xianmu;

public class kache1 extends Car {
public int price=222;
public String carname="卡车2";
public int huoliang=22;
public int renliang=2;
public int number;
@Override
public void price(int number) {
// TODO Auto-generated method stub
System.out.println("总金额为"+(number*price));
}

@Override
public void chexing() {
    // TODO Auto-generated method stub
    System.out.println(carname);
}

@Override
public void zaihuo(int number) {
    // TODO Auto-generated method stub
    System.out.println("总载货量为"+(number*huoliang));
}

@Override
public void zairen(int number) {
    // TODO Auto-generated method stub
    System.out.println("总载人量为"+(number*renliang));
}

}


package com.xianmu;

public class ceshi {

public static void main(String[] args) {
    // TODO Auto-generated method stub
    kache1 a=new kache1();
    kache2 b=new kache2();
    final int qq=3;
    final int ww=5;
    a.chexing();
    a.price(qq);
    a.zaihuo(qq);
    a.zairen(qq);
    b.chexing();
    b.price(ww);
}

}

打开App,阅读手记
0人推荐
发表评论
随时随地看视频慕课网APP