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

📄 motorvehicle.java

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


import java.io.*;


public class Motorvehicle extends veh implements Serializable
{
	int cc;      // cubic centimeters of the engine (e.g. 597) 
    int hp;      //horsepower (e.g. 67)
    
    String LeasePlan;
    
    private static int count_Motorvehicle=0;
    
    public Motorvehicle()
    {
    	Motorvehicle_total();
    }
    public Motorvehicle(int C,int H)
    {
    	Motorvehicle_total();
    	this.cc=C;
    	this.hp=H;
    }
    void setLeasePlan()throws IOException
	{
		boolean valid=false;
		int i=1;
		while(!valid)
		{
			BufferedReader in =new BufferedReader(new InputStreamReader(System.in));
			System.out.print("Input the LeasePlan(1 for daily, 2 for weekly , 3 for monthly, 4 for yearly)):");
			try{
				i=(new Integer(in.readLine())).intValue();
				if( i!=1 && i!=2 && i!=3 && i!=4)
				{
					System.out.println("输入错误!");    
					continue;
				}
				valid=true;
				}catch(NumberFormatException e)
				{
					System.out.println("输入错误!");
				}
		}
		switch(i)
	    {
		case 1:LeasePlan="daily";break;
	    case 2:LeasePlan="weekly";break;
	    case 3:LeasePlan="monthly";break;
	    case 4:LeasePlan="yearly";break;
	    }
	}
    
    public String toString()
	{
    	return(super.toString()+"cc:   "+cc+"\n"+"hp: "+hp+"\n"+"LeasePlan: "+LeasePlan+"\n");
    	
	}
       
    public static void Motorvehicle_total()
	{
		count_Motorvehicle++;
	}
    
    public static int show_count_Motorvehicle()
	{
		return count_Motorvehicle;
	}

    public void addMotorvehicle()throws IOException
    {
    	this.addVehicle();
    	
    	BufferedReader in =new BufferedReader(new InputStreamReader(System.in));
    	boolean valid;
    	
    	valid=false;
			
		while(!valid)
		{
			System.out.print("Input the cubic centimeters of the engine:   ");
			try{
				this.cc=(new Integer(in.readLine())).intValue();
				valid=true;
				}catch(NumberFormatException e)
				{
					System.out.println("输入错误!");
				}
		}
		
		valid=false;
		
		while(!valid)
		{
			System.out.print("Input the horsepower:   ");
			try{
				this.hp=(new Integer(in.readLine())).intValue();
				valid=true;
				}catch(NumberFormatException e)
				{
					System.out.println("输入错误!");
				}
		}
		
		setLeasePlan();
	}

}

⌨️ 快捷键说明

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