重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
这篇文章主要介绍了java怎么实现简单租车系统,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。
10多年的洞口网站建设经验,针对设计、前端、开发、售后、文案、推广等六对一服务,响应快,48小时及时工作处理。全网整合营销推广的优势是能够根据用户设备显示端的尺寸不同,自动调整洞口建站的显示方式,使网站能够适用不同显示终端,在浏览器中调整网站的宽度,无论在任何一种浏览器上浏览网站,都能展现优雅布局与设计,从而大程度地提升浏览体验。创新互联从事“洞口网站设计”,“洞口网站推广”以来,每个客户项目都认真落实执行。
具体内容如下
这也是参考了mooc上的一个基础项目,所以拿来写一下。不过我的Demo肯定有不好或者错误的地方,欢迎指出
1、项目功能/需求
a、展示所有可租车辆
b、选择车型、租车量
c、展示租车清单,包含:总金额、总载货量、总载客量
2、项目系统UML图
3、项目源码Demo
Car类
package Car.rental; public class Car { private String name; private int rent; private int passenger; private double volume; public String getName() { return name; } public void setName(String name) { this.name = name; } public int getRent() { return rent; } public void setRent(int rent) { this.rent = rent; } public int getPassenger() { return passenger; } public void setPassenger(int passenger) { this.passenger = passenger; } public double getVolume() { return volume; } public void setVolume(double volume) { this.volume = volume; } }
Truck类
package Car.rental; public class Truck extends Car { private String name; private int rent; private double volume; public Truck(String name,int rent,double volume) { this.name=name; this.rent=rent; this.volume=volume; } public String getName() { return name; } public void setName(String name) { this.name = name; } public int getRent() { return rent; } public void setRent(int rent) { this.rent = rent; } public double getVolume() { return volume; } public void setVolume(double volume) { this.volume = volume; } }
Coach类
package Car.rental; public class Coach extends Car { private String name; private int rent; private int passenger; public Coach(String name,int rent,int passenger) { this.name=name; this.passenger=passenger; this.rent=rent; } public int getPassenger() { return passenger; } public void setPassenger(int passenger) { this.passenger = passenger; } public String getName() { return name; } public void setName(String name) { this.name = name; } public int getRent() { return rent; } public void setRent(int rent) { this.rent = rent; } }
Pickup类
package Car.rental; public class Pickup extends Car { private String name; private int rent; private int passenger; private double volume; public Pickup(String name,int rent,int passenger,double volume) { this.name=name; this.passenger=passenger; this.rent=rent; this.volume=volume; } public int getPassenger() { return passenger; } public void setPassenger(int passenger) { this.passenger = passenger; } public double getVolume() { return volume; } public void setVolume(double volume) { this.volume = volume; } public String getName() { return name; } public void setName(String name) { this.name = name; } public int getRent() { return rent; } public void setRent(int rent) { this.rent = rent; } }
测试类
package Car.rental; import java.util.Scanner; public class main_Car { public static void main(String[] args) { // TODO Auto-generated method stub /*****创建车对象*******/ /*Car tru=new Truck("拉丝货车",200,1.1); Car coa=new Coach("法法客车",150,20); Car Pic=new Pickup("无名皮卡车",300,4,0.5);*/ Car[] Allcar= {new Truck("拉丝货车",200,1.1),new Coach("法法客车",150,20), new Pickup("无名皮卡车",300,4,0.5)}; System.out.println("请问您是否要租车:1.是 2.否"); Scanner scan=new Scanner(System.in); String input=scan.next(); if(input.equals("1")) { int all_rent = 0;//总租金 int all_passenger=0;//总载客 double all_volume=0.0;//总载货 System.out.println("您可租车的类型及其价目"); System.out.println("序号\t汽车名称\t租金\t容量\t"); for(int i=0;i4、项目命令行演示结果
感谢你能够认真阅读完这篇文章,希望小编分享的“java怎么实现简单租车系统”这篇文章对大家有帮助,同时也希望大家多多支持创新互联,关注创新互联行业资讯频道,更多相关知识等着你来学习!
当前题目:java怎么实现简单租车系统
分享URL:http://cqcxhl.com/article/jihpog.html