📄 veh.java
字号:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Serializable;
class Date implements Serializable
{
int year;
String month;
public Date(){}
public Date(int Y,String M)
{
this.year =Y;
this.month=M;
}
public String toString()
{
return "date:"+month+","+year;
}
public void setDate()throws IOException
{
boolean valid;
BufferedReader in =new BufferedReader(new InputStreamReader(System.in));
valid=false;
int mon = 0;
while(!valid)
{
System.out.print("Input year: ");
try{
year=(new Integer(in.readLine())).intValue();
valid=true;
}catch(NumberFormatException e)
{
System.out.println("输入错误!");
}
}
valid=false;
while(!valid)
{
System.out.print("Input month: ");
try{
mon=(new Integer(in.readLine())).intValue();
if(mon<1||mon>12)
{
System.out.println("输入错误!");
continue;
}
valid=true;
}catch(NumberFormatException e)
{
System.out.println("输入错误!");
}
}
switch(mon)
{
case 1:month="January";break;
case 2:month="February";break;
case 3:month="March";break;
case 4:month="April";break;
case 5:month="May";break;
case 6:month="June";break;
case 7:month="July";break;
case 8:month="August";break;
case 9:month="September";break;
case 10:month="October";break;
case 11:month="November";break;
case 12:month="December";break;
}
}//"March""April""May""June""July""August""September""October""November""December"
}
abstract class veh implements Serializable
{
String ID;
String type;
String name;
Date date = new Date();
float value;
static int count_vehicle=0;
public veh()
{
vehicle_total();
this.ID=String.format("%04d", veh.count_vehicle);
}
public veh(String N,float V)
{
vehicle_total();
this.ID=String.format("%04d", veh.count_vehicle);
this.name=N;
this.value=V;
}
abstract void setLeasePlan()throws IOException;
public String toString()
{
return "ID: "+ID+"\n"
+"type: "+type+"\n"
+"name: "+name+"\n"
+date+"\n";
}
public static void vehicle_total()
{
count_vehicle++;
}
public static int show_count_vehicle()
{
return count_vehicle;
}
public void addVehicle()throws IOException
{
BufferedReader in =new BufferedReader(new InputStreamReader(System.in));
System.out.print("Input name: ");
this.name=in.readLine();
boolean valid=false;
while(!valid)
{
try{
System.out.print("Input value: ");
value=(new Integer(in.readLine())).intValue();
valid=true;
}catch(NumberFormatException e)
{
System.out.println("输入错误!");
}
}
this.date=new Date();
this.date.setDate();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -