JAVA答答打车系统代码_java进阶.答答打车系统

继承的两个抽象类里面的两个抽象方法如下:

public abstract class Capacity{

public abstract int passengerCapacity(int e[], int d);

public abstract int carryingCapacity(int s[], int b);

}

主类调用并实现功能:

import java.util.Scanner;

public class Text extends Capacity{

@Override

public int passengerCapacity(int e[], int d){

int humannumber=0;

int money=0;

int eeeee = 0,ee = 0, eee = 0, eeee= 0;

for(int j = 0; j

if(e[j] == 1){

eeeee = eeeee+1;

System.out.print("奥迪A4: "+ eeeee+"辆 ");

humannumber = humannumber+4;

money = money+500;

}

else if(e[j] == 2){

ee = ee + 1;

System.out.print("马自达6: "+ ee +"辆 ");

humannumber = humannumber+4;

money = money + 400;

}

else if(e[j] == 3 ){

eee = eee +1;

System.out.print("皮卡雪6: "+ eee+ "辆 ");

humannumber = humannumber+4;

money = money + 450;

}

else if(e[j] == 4 ){

eeee = eeee +1;

System.out.print("金龙: "+eeee +"辆 ");

humannumber = humannumber+20;

money = money + 800;

}

}

System.out.print("总载客量为: ");

System.out.println(humannumber);

return money;

}

@Override

public int carryingCapacity(int e[], int d){

int goodsquantity=0;

int money=0;

int o =0,oo = 0, ooo = 0;

for(int j = 0; j

if(e[j] == 3){

o = o+1;

System.out.print("皮卡雪6: "+ o +"辆 ");

goodsquantity = goodsquantity + 2;

}

else if(e[j] == 5){

oo = oo+1;

System.out.print("松花江: "+ oo +"辆 ");

goodsquantity = goodsquantity + 4;

money = money + 400;

}

else if(e[j] == 6 ){

ooo = ooo+1;

System.out.print("依维柯: "+ ooo +"辆 ");

goodsquantity = goodsquantity + 200;

money = money + 450;

}

}

System.out.print("总载货量为: ");

System.out.println(goodsquantity);

return money;

}

public static void main(String[] args){

System.out.println("您是否需要呼叫张宸打车系统:1需要,0不需要");

Scanner a = new Scanner(System.in);

int b = a.nextInt();

if(b == 1){

System.out.println("序号 汽车名称 租金 容量");

System.out.println(" 1 奥迪A4 500元/天 载人:4人");

System.out.println(" 2 马自达6 400元/天 载人:4人");

System.out.println(" 3 皮卡雪6 450元/天 载人:4载货:2吨");

System.out.println(" 4 金龙 800元/天 载人:20人");

System.out.println(" 5 松花江 400元/天 载货:4吨");

System.out.println(" 6 依维柯 1000元/天 载货:200吨");

System.out.println("请输入您要选车辆数:");

Scanner c = new Scanner(System.in);

int d = c.nextInt();

int[] e = new int[d];

int k = 0;

for(int i =0 ; i

k=i+1;

System.out.println("请输入您要选择的第"+ k +"辆车的序号");

Scanner f = new Scanner(System.in);

e[i]= f.nextInt();

}

int z = 0;

Text text = new Text();

z = text.passengerCapacity(e,d) + text.carryingCapacity(e,d);

System.out.println("总价钱为: " + z);

}

}

}

AAffA0nNPuCLAAAAAElFTkSuQmCC

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值