ITPub博客

首页 > IT职业 > IT生活 > 答答租车系统,加入修改车价目的功能

答答租车系统,加入修改车价目的功能

IT生活 作者:johnchou 时间:2021-09-09 09:06:07 0 删除 编辑

表示不是很清楚有哪些车,不过没关系。

客户页面

package rental;
import java.util.Scanner;
public class Client {

    //for不能一直循环下去,所以定了个200的上限,这个还得考虑

    public static void main(String[] args) {

        double sum=0;//总租金..............................................

        JiaoChe jiaoChe=new JiaoChe(); 
        HuoChe huoChe=new HuoChe();
        MianBao mianBao=new MianBao();
        KaChe kaChe=new KaChe();

        System.out.println("欢迎使用答答租车系统nn"+"您是否要租车?  1.是的  2.我不要租车 n");

        if(new Scanner(System.in).nextInt()==1)
            ;
        else
            System.exit(0);

        for(int count=0;count

轿车代码

package rental;

public class JiaoChe implements People{

        String property="轿车";
        String type="大众";
        double costs=1000;

    public void details() {
        System.out.println("1、类别:"+property+"   型号:"+type+"   月租费:"+costs+"/月"+
                "   备注:"+str);
    }
}

货车代码

package rental;

public class HuoChe implements Goods{

        String property="货车";
        String type="福田";
        double costs=800;

    public void details() {
        System.out.println("2、类别:"+property+"   型号:"+type+"   月租费:"+costs+"/月"+
                "   备注:"+str);
}
}

面包车代码

package rental;

public class MianBao implements People,Goods{

        String property="面包车";
        String type="长安";
        double costs=850;

    public void details() {
        System.out.println("3、类别:"+property+"   型号:"+type+"   月租费:"+costs+"/月"+
                "   备注:"+People.str+""+Goods.str);
}
}

卡车

package rental;

public class KaChe implements Goods{

        String property="卡车";
        String type="福田";
        double costs=900;

    public void details() {
        System.out.println("4、类别:"+property+"   型号:"+type+"   月租费:"+costs+"/月"+
                "   备注:"+People.str+""+Goods.str);
}
}

有点鸡肋的接口。。

package rental;

public interface Goods {

    String str="运输货物";
}
package rental;

public interface People {

    String str="运输人员";
}

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/4422/viewspace-2808059/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2020-11-13

  • 博文量
    80
  • 访问量
    7438