还有许多小瑕疵,以后还会有增删。目前先这样。
IN方法(主要函数)
package ZCXT;
import java.util.Scanner;
public class IN {
static jszs2 I=new jszs2();
public static void main(String[] args) {
IN q=new IN();
q.put();
}
{
for(;true;) {
System.out.println(“欢迎使用租车系统”);
System.out.println(“是否租车”);
Scanner input=new Scanner(System.in);
String in=input.next();
if(in.equals(“是”)){
System.out.println(“本公司共有载货,载人,混载。三类”);
System.out.println(“请问选哪种”);
in=input.next();
if(in.equals(“载货”)) {
System.out.println(“货车类型共有:”);
ZH i=new ZH(1,“松花江”,4,400);
System.out.println(i.ID+" “+i.name+“价钱”+i.mon+“载货量”+i.sum);
ZH i2=new ZH(2,“依维柯”,10,1000);
System.out.println(i2.ID+” “+i2.name+“价钱”+i2.mon+“载货量”+i2.sum);
jszs w=new jszs();
for(;true;) {
System.out.println(“租哪辆?(输入ID)”);
int in1=input.nextInt();
in1=input.nextInt();
if(in11) {
w.mon(i.mon);
w.Rsum(i.sum);
w.name(i.name);
I.ZRsum(i.sum);
I.name(i.name);
I.mon(i.mon);
System.out.println(“是否继续租货车?”);
in=input.next();
if(in.equals(“是”)) {
continue;
}else if(in.equals(“否”)) {
break;
}else {
System.out.println(“重新输入”);
w.Rsum(-(i.sum));
I.ZRsum(-(i.sum));
I.name(i.name);
I.mon(i.mon);
continue;
}
}else if(in12) {
w.mon(i2.mon);
w.Rsum(i2.sum);
w.name(i2.name);
I.ZRsum(i2.sum);
I.name(i2.name);
I.mon(i2.mon);
System.out.println(“是否继续租货车?”);
in=input.next();
if(in.equals(“是”)) {
continue;
}else if(in.equals(“否”)) {
break;
}else {
System.out.println(“重新输入”);
w.Rsum(-(i2.sum));
I.ZRsum(-(i2.sum));
I.name(i2.name);
I.mon(i2.mon);
continue;
}
}else {
System.out.println(“输入有误,重新输入”);
continue;
}
}
System.out.println(“是否继续租车”);
in=input.next();
if(in.equals(“是”))
continue;
else if(in.equals(“否”)){
System.out.println(“谢谢”);
break;
}
else {
System.out.println(“输入有误,跳出至程序口,重新输入”);
}
}
else if(in.equals(“载人”)) {
System.out.println(“客车类型共有:”);
ZR i=new ZR(1,“奥迪A4”,4,500);
System.out.println(i.ID+” “+i.name+” 价钱"+i.mon+" 载人量"+i.sum);
ZR i2=new ZR(2,“马自达6”,4,400);
System.out.println(i2.ID+" “+i2.name+” 价钱"+i2.mon+" 载人量"+i2.sum);
ZR i3=new ZR(3,“金龙”,20,800);
System.out.println(i3.ID+" “+i3.name+” 价钱"+i3.mon+" 载人量"+i3.sum);
jszs w=new jszs();
for(;true;) {
System.out.println(“租哪辆?(输入ID)”);
int in1=input.nextInt();
if(in11) {
w.Hsum(i.sum);
w.name(i.name);
w.mon(i.mon);
I.ZRsum(i.sum);
I.name(i.name);
I.mon(i.mon);
System.out.println(“是否继续租客车?”);
in=input.next();
if(in.equals(“是”))
continue;
else if(in.equals(“否”))
break;
else {
System.out.println(“重新输入”);
w.Hsum(-(i.sum));
w.mon(-i.mon);
I.ZRsum(-(i.sum));
I.mon(-i.mon);
continue;
}
}else if(in12) {
w.Hsum(i2.sum);
w.name(i2.name);
w.mon(i2.mon);
I.ZRsum(i2.sum);
I.name(i2.name);
I.mon(i2.mon);
System.out.println(“是否继续租客车?”);
in=input.next();
if(in.equals(“是”))
continue;
else if(in.equals(“否”))
break;
else {
System.out.println(“重新输入”);
w.Hsum(-(i2.sum));
w.mon(-i2.mon);
I.ZHsum(-i2.sum);
I.mon(-i2.mon);
continue;
}
}else if(in13) {
w.Hsum(i3.sum);
w.name(i3.name);
w.mon(i3.mon);
I.ZRsum(i3.sum);
I.name(i3.name);
I.mon(i3.mon);
System.out.println(“是否继续租客车?”);
in=input.next();
if(in.equals(“是”))
continue;
else if(in.equals(“否”))
break;
else {
System.out.println(“重新输入”);
w.Hsum(-(i3.sum));
w.mon(-i3.mon);
I.ZRsum(-i3.sum);
I.mon(-i3.mon);
continue;
}
}else {
System.out.println(“输入有误,重新输入”);
continue;
}
}
System.out.println(“是否继续租车”);
in=input.next();
if(in.equals(“是”))
continue;
else if(in.equals(“否”)){
System.out.println(“谢谢”);
break;
}
else {
System.out.println(“输入有误,跳出至程序口,重新输入”);
}
}
else if(in.equals(“混载”)) {
System.out.println(“混合类型共有:”);
ZRHZH i=new ZRHZH(1,“皮卡雪6”,4,2,450);
System.out.println(i.ID+" “+i.name+” 价钱"+i.mon+" 载人量"+i.Rsum+" 载货量"+i.Hsum);
jszs w=new jszs();
for(;true;) {
System.out.println(“租哪辆?(输入ID)”);
int in1=input.nextInt();
if(in11) {
w.Hsum(i.Hsum);
w.Rsum(i.Rsum);
w.name(i.name);
w.mon(i.mon);
I.name(i.name);
I.ZHsum(i.Hsum);
I.ZRsum(i.Rsum);
I.mon(i.mon);
System.out.println(“是否继续租混合型?”);
in=input.next();
if(in.equals(“是”)) {
continue;
}else if(in.equals(“否”)) {
break;
}else {
System.out.println(“重新输入”);
w.Hsum(-(i.Hsum));
w.Rsum(-(i.Rsum));
w.mon(-i.mon);
I.mon(-i.mon);
I.ZHsum(-i.Hsum);
I.ZRsum(-i.Rsum);
continue;
}
}else {
System.out.println(“输入有误,重新输入”);
continue;
}
}
}
}else if(in.equals(“否”)) {
System.out.println(“谢谢”);
}else {
System.out.println(“输入有误请重新输入”);
}
}
}
void put() {
System.out.println(“总租用车辆”+I.name+"/n(能力有限,重复的车辆名有可能是系统残留,请自行识别)");
System.out.println(“总价钱:”+I.mon);
System.out.println(“总人数:”+I.Rsum);
System.out.println(“总载货量:”+I.Hsum);
}
}
载货数据存放类
package ZCXT;
public class ZH {
int ID;
String name;
int sum;
int mon;
public ZH(int s,String i,int j,int z) {
ID=s;
name=i;
sum=j;
mon=z;
}
}
载人数据存放类
package ZCXT;
public class ZR {
int ID;
String name;
int sum;
int mon;
public ZR(int s,String i,int j,int z) {
ID=s;
name=i;
sum=j;
mon=z;
}
}
混载数据存放类
package ZCXT;
public class ZRHZH {
int ID;
String name;
int Hsum;
int Rsum;
int mon;
public ZRHZH(int s,String i,int j,int z,int m) {
ID=s;
name=i;
Rsum=j;
Hsum=z;
mon=m;
}
}
分车型计算类
package ZCXT;
public class jszs {
int Rsum;
int mon;
int Hsum;
String name;
public void Rsum(int w) {
Rsum+=w;
}
public void Hsum(int w) {
Hsum+=w;
}
public void mon(int w) {
mon+=w;
}
public void name(String w) {
name+=","+w;
}
}
总计算类
package ZCXT;
public class jszs2 {
int Rsum;
int Hsum;
int mon;
String name="";
void ZRsum(int w) {
Rsum+=w;
}
void ZHsum(int w) {
Hsum+=w;
}
void name(String w) {
name+=" "+w;
}
void mon(int w) {
mon+=w;
}
}
共同学习,写下你的评论
评论加载中...
作者其他优质文章