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

📄 hirereport.java

📁 比较简单的vechilesystem代码还没经过优化
💻 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 + -