package 租车系统;
import java.util.*;
public class rukou {
public static void main(String[] args) {
// TODO 自动生成的方法存根
Ad AD=new Ad();
Mzd MZD=new Mzd();
Pkx PKX=new Pkx();
Jl JL=new Jl();
Shj SHJ=new Shj();
Ywk YWK=new Ywk();
Gz gz=new Gz();
Tj tj=new Tj();
int ad=0;
int mzd=0;
int pkx=0;
int jl=0;
int shj=0;
int ywk=0;
Scanner input=new Scanner(System.in);
System.out.println("欢迎使用答答租车系统");
System.out.println("您是否要租车:1是 2否");
int xz=input.nextInt();
if(xz==1)
{
System.out.println("您可租车的类型及其价目表:");
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元/天----载货:20吨");
System.out.println("请输入您要租汽车的数量:");
int sl=input.nextInt();
if(sl>=0)
{
for(int i=1;i<=sl;i++)
{
System.out.println("请输入第"+i+"辆车的序号:");
int xh=input.nextInt();
if(xh>=1&&xh<=6)
{
switch(xh) {
case 1:ad++;
case 2:mzd++;
case 3:pkx++;
case 4:jl++;
case 5:shj++;
case 6:ywk++;
break;
}
}else
{
System.out.println("输入有误,请重新输入");
i--;
}
}
}else
System.out.println("输入有误,请重新输入");
}else
{
System.out.println("感谢使用!");
}
System.out.println("请输入租车天数:");
int day=input.nextInt();
System.out.println("可载人的车有:");
tj.zr(ad, mzd, pkx, jl);
System.out.println("共载人:"+gz.gzr(ad, mzd, pkx, jl));
System.out.println("载货的车有");
tj.zh(pkx, shj, ywk);
System.out.println("共载货:"+gz.gzh(pkx, shj, ywk));
}
}
package 租车系统;
public abstract class Car {
public int zr(){
int zr=0;
return zr;
}
public int zw() {
int zh=0;
return zh;
}
public int rmb() {
int rmb=0;
return rmb;
}
}
package 租车系统;
public class Ad extends Car {
public int zr(){
int zr=4;
return zr;
}
public int rmb(){
int rmb=500;
return rmb;
}
}
package 租车系统;
public class Mzd extends Car {
public int zr(){
int zr=4;
return zr;
}
public int rmb() {
int rmb=400;
return rmb;
}
}
package 租车系统;
public class Pkx extends Car {
public int zr(){
int zr=4;
return zr;
}
public int zw() {
int zh=2;
return zh;
}
public int rmb() {
int rmb=450;
return rmb;
}
}
package 租车系统;
public class Jl extends Car {
public int zr(){
int zr=20;
return zr;
}
public int rmb() {
int rmb=800;
return rmb;
}
}
package 租车系统;
public class Shj extends Car {
public int zw() {
int zh=4;
return zh;
}
public int rmb() {
int rmb=400;
return rmb;
}
}
package 租车系统;
public class Ywk extends Car {
public int zw() {
int zh=20;
return zh;
}
public int rmb() {
int rmb=1000;
return rmb;
}
}
package 租车系统;
public class Gz{
public int gzr(int ad,int mzd,int pkx,int jl) {
int zrsum;
zrsum=ad*4+mzd*4+pkx*4+jl*20;
return zrsum;
}
public int gzh(int pkx,int shj,int ywk) {
int zhsum=pkx*2+shj*4+ywk*2;
return zhsum;
}
}
package 租车系统;
public class Tj {
public void zr(int ad,int mzd,int pkx,int jl){
if(ad>0)
System.out.print("奥迪A4 ");
if(mzd>0)
System.out.print("马自达6 ");
if(pkx>0)
System.out.print("皮卡雪 ");
if(jl>0)
System.out.print("金龙 ");
}
public void zh(int pkx,int shj,int ywk) {
if(pkx>0)
System.out.print("皮卡雪 ");
if(shj>0)
System.out.print("松花江 ");
if(ywk>0)
System.out.print("依维柯 ");
}
}
包名的命名规范好像是小写,还是尽量不要用汉语
有个建议。最好变量名不要这么写,根据功能用英语写,这样子别人要看懂你的代码比较容易
知道问题了,少了几个break?