Java编写汽车租赁系统

更新时间:2023-07-23 04:02:54 阅读: 评论:0

Java编写汽车租赁系统题⽬要求:
1、汽车租赁信息表如下:
2、类和属性:
3、运⾏效果:
效果实现:
代码实现:
1、车类:
am;
public abstract class Vehicle {
private String num;
private String brand;
private double rent;
public String getNum(){
return num;
}
public void tNum(String num){
this.num = num;
}
public String getBrand(){
return brand;
}
public void tBrand(String brand){
this.brand = brand;
}
public double getRent(){
return rent;
保教是什么意思}
public void tRent(double rent){
< = rent;
}
public Vehicle(){
}
//含参构造
public Vehicle(String num, String brand,double rent){
this.num = num;
this.brand = brand;
< = rent;
}
@Override
public String toString(){
return"汽车{"+
"车牌号='"+ num +'\''+
", 品牌='"+ brand +'\''+
3xxx", ⽇租⾦="+ rent +
'}';
}
public abstract double totalmoney(int days ,double rent); public abstract boolean equals(Vehicle o);
}
2、汽车类:
public String getType() {
return type;
}
public void tType(String type) {
}
public Cars(String brand,String type) {
}
public Cars(String num, String brand, double rent, String type) {
super(num, brand, rent);
}
@Override
public String toString() {
return "Cars{" +
"type='" + type + '\'' +
'}';
}
//计算⼩汽车的总租⾦
对会计专业的认识@Override日本投降
public double totalmoney(int days, double rent) {
if (days>7){
return days*rent*0.9;
}el if (days>30){
return days*rent*0.8;
}el if (days>150){
return days*rent*0.7;
}
return days*rent;
}
//重写equals⽅法
@Override
public boolean equals(Vehicle o) {
if (o instanceof Cars){
Cars cars= (Cars) o;
Type().Type())&&Brand().Brand());        }
return fal;
}
}
3、客车类:
public String getSeat(){
return at;
}
public void tSeat(String at){
this.at = at;
}
public Bus(String num, String brand,double rent, String at){ super(num, brand, rent);
this.at = at;
}
/
/计算客车的租⾦
@Override
public double totalmoney(int days,double rent){
if(days>=3){
return days*rent*0.9;
}el if(days>=7){
return days*rent*0.8;
}el if(days>=30){
return days*rent*0.7;
花图片简笔画}el if(days>=150){
return days*rent*0.6;
}
return days*rent;
}
//重写equals⽅法
@Override
public boolean equals(Vehicle o){
return fal;
}
}
4、车辆管理类:
am;
public class CarRent {
//创建汽车数组,将汽车的信息放在数组中
public Cars[] carMake(){
Cars c1 = new Cars("京NY28588", "宝马", 800, "x6");
Cars c2 = new Cars("京CNY3284", "宝马", 600, "550i");
Cars c3 = new Cars("京NT37465", "别克", 300, "林荫⼤道");        Cars c4 = new Cars("京NT96928", "别克", 600, "GL8");
Cars[] arr1 ={c1,c2,c3,c4};
return arr1;
}
//创建客车数组,将汽车的信息放在数组中
public Bus[] busMake(){
Bus b1 = new Bus("京6566754", "⾦杯", 800, "16座");
Bus b2 = new Bus("京8696667", "⾦龙", 800, "16座");
Bus b3 = new Bus("京9696996", "⾦杯", 1500, "34座");
Bus b4 = new Bus("京8696998", "⾦龙", 1500, "34座");
Bus[] arr2={b1,b2,b3,b4};
return arr2;
}
}
5、业务服务类:
am;
import java.util.Scanner;
public class CarService {
public void rentcar(){
System.out.println("**********欢迎光临秋名⼭守望者汽车租赁公司**********");
Scanner sc =new Scanner(System.in);
System.out.println("1,轿车  2,客车");
System.out.print("请输⼊您要租赁的汽车类型:");
int i = sc.nextInt();
CarRent carRent =new CarRent();//创建车库对象
Cars[] cars = carRent.carMake();//拿到轿车数组对象
Cars car=null;
Bus[] bus = carRent.busMake();//拿到客车数组对象
Bus bus=null;
五停心观//判断⽤户选择的车型
if(i==1){
System.out.print("请选择你要租赁的汽车品牌:(1,别克  2,宝马)");
int i1 = sc.nextInt();
if(i1==1){
System.out.print("请输⼊你要租赁的汽车类型:(1,林荫⼤道 2,GL8 )");
}el{
雷锋语录
System.out.print("请输⼊你要租赁的汽车类型:(1,x6 2,550i )");
}
String i2 = sc.next();
/
/遍历汽车数组,拿到⽤户选择的汽车
for(int j =0; j < cars.length; j++){
if(cars[j].getType().equals(i2)){//当选择的车的类型与数组中的匹配时
car=cars[j];//将车赋值给car
break;
}
}
System.out.print("请输⼊你要租赁的天数:");
int days = sc.nextInt();
System.out.print("分配给你的汽车牌号是:");
System.out.Num());//获取汽车的车牌
double totalmoney =0;//调⽤total
totalmoney = almoney(days, Rent());//计算⽤户的租⾦
System.out.print("你需要⽀付的租赁分费⽤是:");
System.out.print(totalmoney);
}el if(i==2){
presdSystem.out.print("请选择你要租赁的汽车品牌:(1,⾦龙  2,⾦杯)");
String i2 = sc.next();
System.out.print("请输⼊你要租赁的汽车座位数:(1,16座  2,34座)");
String i3 = sc.next();
//遍历客车数组,拿到⽤户选择的客车
for(int j =0; j < bus.length; j++){
/
/当输⼊的客车的车牌和座位与数组中的相等,就选出⽤户选择的车
if(bus[j].getBrand().equals(i2)&&bus[j].getSeat().equals(i3)){
bus=bus[j];//将选择的车辆赋值给bus
break;
}
}
System.out.print("请输⼊你要租赁的天数:");
int days = sc.nextInt();
System.out.print("分配给你的汽车牌号是:");
System.out.println();
System.out.Num());//拿到⽤户选择的车牌号
double totalmoney =0;//调⽤totalmoney⽅法
almoney(days, Rent());//⽤⽤户输⼊的天数。来计算租⾦            System.out.print("你需要⽀付的租赁分费⽤是:");
System.out.print(totalmoney);

本文发布于:2023-07-23 04:02:54,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/89/1092859.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:汽车   租赁   数组   选择   拿到
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图