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

📄 bike.java

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


import java.io.*;


public class Bike extends veh implements Property,Serializable
{
	boolean horn;   //true(false) if it has(not) a horn
	boolean lights; //true(false) if it has(not) a lights
	private static int count_Bike=0;
	private static String BikeAdmin="BikePerson";
	leaser bikeleaser;
	
	String LeasePlan;
	
	public Bike()
	{
		Bike_total();
	}
	public Bike(String T,String N,int v,boolean H,boolean L,String M,int Y)
	{
		Bike_total();
		this.name=N;
		this.type=T;
		this.value=v;
		this.horn=H;
		this.lights=L;
		this.ID=String.format("%04d", veh.count_vehicle);
		this.date.year=Y;
		this.date.month=M;
	}
	
	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):");
			try{
				i=(new Integer(in.readLine())).intValue();
				if(i!=1&&i!=2)
				{
					System.out.println("输入错误!");    
					continue;
				}
				valid=true;
				}catch(NumberFormatException e)
				{
					System.out.println("输入错误!");
				}
		}
		switch(i)
	    {
		case 1:LeasePlan="daily";break;
	    case 2:LeasePlan="weekly";break;
	    }
	}
	
	public float calculateValue()
	{
		return (float) (value*0.3);
	}
	
	public String getAdmin()
	{
		return BikeAdmin;
	} 
	
		
	public String toString()
	{
		return(super.toString()+"horn:   "+horn+"\n"+"lights: "+lights+"\n"+"LeasePlan: "+LeasePlan+"\n"+
		         "the person responsible for this vehicle:"+getAdmin()+"\n"+
		         "estimated value  :"+calculateValue()+"\n"+bikeleaser+"\n\n");
	}
	
	public static void Bike_total()
	{
		count_Bike++;
	}
	
	public static int show_count_Bike()
	{
		return count_Bike;
	}
	
		
	public void addBike()throws IOException
    {
		this.addVehicle();
		
		BufferedReader in =new BufferedReader(new InputStreamReader(System.in));
		
		boolean valid;
		
		valid=false;
		
		String p;
		
		while(!valid)
		{
			System.out.print("Dose it have a horn (Y or N):   ");
			
			p=in.readLine();
			
			if(p.equalsIgnoreCase("Y")||p.equalsIgnoreCase("y"))
			{
				this.horn=true;
				valid=true;
			}
			else if(p.equalsIgnoreCase("N")||p.equalsIgnoreCase("n"))
			{
				this.horn=false;
				valid=true;
			}
			else System.out.println("输入错误!");
		}
		
		valid=false;
		
		while(!valid)
		{
			System.out.print("Dose it have a lights (Y or N):   ");
			
			p=in.readLine();
			
			if(p.equalsIgnoreCase("Y")||p.equalsIgnoreCase("y"))
			{
				this.lights=true;
				valid=true;
			}
			else if(p.equalsIgnoreCase("N")||p.equalsIgnoreCase("n"))
			{
				this.lights=true;
				valid=true;
			}else System.out.println("输入错误!");
		}
		
		setLeasePlan();
		
		this.bikeleaser=new leaser();
		this.bikeleaser.set_leaser();
		
	}

}

⌨️ 快捷键说明

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