?? motorvehicle.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 + -