?? hirereport.java
字號:
/**
* Created by IntelliJ IDEA.
* User: Ray
* Date: 2008-4-8
* Time: 13:08:04
* To change this template use File | Settings | File Templates.
*/
package report;
import vehicleinfo.Vehicle;
import java.text.DecimalFormat;
public class HireReport {
private Vehicle vehicle;
private static final int YUAN_PER_MILE=45;
public static final String NEWLINE=System.getProperty("line.separator");
public static final String HIRE_REPORT_HEADER="Vehicle"+NEWLINE+"----"+NEWLINE;
public static final String HIRE_REPORT_FOOTER=NEWLINE+"# Expense=";
public HireReport(Vehicle vehicle){
this.vehicle=vehicle;
}
public String getReport() {
StringBuilder buffer=new StringBuilder();
buffer.append(HIRE_REPORT_HEADER);
buffer.append("Type:"+vehicle.getVehicleType());
buffer.append(NEWLINE);
buffer.append("Registration:"+vehicle.getRegistration());
buffer.append(NEWLINE);
buffer.append("Colour:"+vehicle.getColour());
buffer.append(NEWLINE);
buffer.append("Before be hired:"+vehicle.getCurruntMileage());
buffer.append(NEWLINE);
buffer.append("Now:"+vehicle.getNewMileage());
buffer.append(NEWLINE);
double expense=(vehicle.getNewMileage()-vehicle.getCurruntMileage())*YUAN_PER_MILE;
DecimalFormat df2 = new DecimalFormat("###.00");
buffer.append(HIRE_REPORT_FOOTER+df2.format(expense)+"Yuan"+NEWLINE);
return buffer.toString();
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -