⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 car.java

📁 一个租车行的图形用户界面程序,可根据顾客的要求选择车辆
💻 JAVA
字号:


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Car extends Motorvehicle implements Property
{
	int seats; 		//number of seats
	int airbags; 	//number of airbags
	leaser carleaser;
	private static int count_car=0;
	
	private static String CarAdmin="CarPerson";
	
	public Car()
	{
		car_total();
	}
	public Car(String T,String N,int C,int H,int S,int A,int V,String M,int Y)
	{
		car_total();
		this.type=T;
		this.name=N;
		this.ID=String.format("%04d", veh.count_vehicle);
		this.cc=C;
		this.hp=H;
		this.seats=S;
		this.airbags=A;
		this.value=V;
		this.date.month=M;
		this.date.year=Y;
	}
	public float calculateValue()
	{
		return (float) (value*0.7);
	}
	
	public String getAdmin()
	{
		return CarAdmin;
	}
	
	public String toString()
	{
		return(super.toString()+"seats:   "+seats+"\n"+"airbages: "+airbags+"\n"+
		         "the person responsible for this vehicle:"+getAdmin()+"\n"+
		         "estimated value:  "+calculateValue()+"\n"+carleaser+"\n\n");
	}
	
	public static void car_total()
	{
		count_car++;
	}
	
	public static int show_count_car()
	{
		return count_car;
	}
	
	public void addCar()throws IOException
    {
		this.addMotorvehicle();
		
		BufferedReader in =new BufferedReader(new InputStreamReader(System.in));
		
boolean valid;
		
		valid=false;
		
		while(!valid)
		{
			System.out.print("Input the number of the seats:   ");
			try{
				this.seats=(new Integer(in.readLine())).intValue();
				valid=true;
				}catch(NumberFormatException e)
				{
					System.out.println("输入错误!");
				}
		}
		valid=false;
		
		while(!valid)
		{
			System.out.print("Input the number of the airbags:   ");
			try{
				this.airbags=(new Integer(in.readLine())).intValue();
				valid=true;
				}catch(NumberFormatException e)
				{
					System.out.println("输入错误!");
				}
		}
		this.carleaser=new leaser();
		this.carleaser.set_leaser();
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -