为了账号安全,请及时绑定邮箱和手机立即绑定

java达达租车系统

标签:
Java

入口类IN

package ZCXT;
import java.util.Scanner;
public class IN {
	jszs2 I=new jszs2();
	public static void main(String[] args) {
		IN q=new IN();
		q.put();
	}
	{
		System.out.println("欢迎使用租车系统");
		System.out.println("是否租车");
		Scanner input=new Scanner(System.in);
		String in=input.next();
		for(;true;) {
			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();
						if(in1==1) {
							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.mon(-i.mon);
								continue;
							}
						}else if(in1==2) {
							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.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(in1==1) {
							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(in1==2) {
							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(in1==3) {
							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(in1==1) {
							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;
						}
					}
					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("谢谢");
				break;
			}else {
				System.out.println("输入有误请重新输入");
			}
		}
	}
	void put() {
		System.out.println("总租用车辆:"+I.name+"    (能力有限,重复的车辆名有可能是系统残留,请自行识别)");
		System.out.println("总价钱:"+I.mon);
		System.out.println("总人数:"+I.Rsum);
		System.out.println("总载货量:"+I.Hsum);
	}
}

载人存放数据类

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 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 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;
	}
}
点击查看更多内容
TA 点赞

若觉得本文不错,就分享一下吧!

评论

作者其他优质文章

正在加载中
  • 推荐
  • 评论
  • 收藏
  • 共同学习,写下你的评论
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦
今天注册有机会得

100积分直接送

付费专栏免费学

大额优惠券免费领

立即参与 放弃机会
意见反馈 帮助中心 APP下载
官方微信

举报

0/150
提交
取消