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

📄 vehdata.java

📁 Vehicle Maintenance Tracker (VMT) 可以对多个车辆的维护进行跟踪。项目类似于Auto-Do-It
💻 JAVA
字号:
package jMaint;import java.util.*;public class VehData {    Vector id,name,year,make,mod,vin,lic,p_date,p_odo,p_ven,p_tot,com,act,meas;    public VehData() {        id = new Vector();        name = new Vector();        year = new Vector();        make = new Vector();        mod = new Vector();        vin = new Vector();        lic = new Vector();        p_date = new Vector();        p_odo = new Vector();        p_ven = new Vector();        p_tot = new Vector();        com = new Vector();        act = new Vector();        meas = new Vector();    }    public void addRecord(int ID, String Name, int Year, String Make, String Model, String VIN, String License, String PurchaseDate, int PurchaseOdometer, int PurchaseVendorID, float PurchaseTotal, String Comment, String Active, String Measurement) {        this.id.addElement(new Integer(ID));        this.name.addElement(new String(Name));        this.year.addElement(new Integer(Year));        this.make.addElement(new String(Make));        this.mod.addElement(new String(Model));        this.vin.addElement(new String(VIN));        this.lic.addElement(new String(License));        this.p_date.addElement(new String(PurchaseDate));        this.p_odo.addElement(new Integer(PurchaseOdometer));        this.p_ven.addElement(new Integer(PurchaseVendorID));        this.p_tot.addElement(new Float(PurchaseTotal));        this.com.addElement(new String(Comment));        this.act.addElement(new String(Active));        this.meas.addElement(new String(Measurement));    }    public Vector createNameVector() {        Vector v = new Vector();        for (int i=0; i<this.size(); i++)            v.addElement(new String(this.getName(i)));        return v;    }    public void deleteRecord(int x) {        this.id.removeElementAt(x);        this.name.removeElementAt(x);        this.year.removeElementAt(x);        this.make.removeElementAt(x);        this.mod.removeElementAt(x);        this.vin.removeElementAt(x);        this.lic.removeElementAt(x);        this.p_date.removeElementAt(x);        this.p_odo.removeElementAt(x);        this.p_ven.removeElementAt(x);        this.p_tot.removeElementAt(x);        this.com.removeElementAt(x);        this.act.removeElementAt(x);        this.meas.removeElementAt(x);    }    public void editRecord(int x, String Name, int Year, String Make, String Model, String VIN, String License, String PurchaseDate, int PurchaseOdometer, int PurchaseVendorID, float PurchaseTotal, String Comment, String Active, String Measurement) {        int ID = this.getID(x);        this.deleteRecord(x);        this.insertRecord(ID, Name, Year, Make, Model, VIN, License, PurchaseDate, PurchaseOdometer, PurchaseVendorID, PurchaseTotal, Comment, Active, Measurement);    }    public String exportRecord(int x) {        String t = String.valueOf('\t');        String nl = String.valueOf('\n');        String a = "T";        if (!this.getActive(x))            a = "F";        String m = "E";        if (!this.getMeasurementUnits(x))            m = "M";        return this.getID(x)+t+this.getName(x)+t+this.getYear(x)+t+this.getMake(x)+t+this.getModel(x)+t+this.getVIN(x)+t+this.getLicense(x)+t+this.getPurchaseDate(x)+t+this.getPurchaseOdometer(x)+t+this.getPurchaseVendorID(x)+t+this.getPurchaseCost(x)+t+this.getComment(x)+t+a+t+m+nl;    }    public boolean getActive(int x) {        boolean y = true;        if (this.act.get(x).toString().equalsIgnoreCase("F"))            y = false;        return y;    }    public String getComment(int x) {        return this.com.get(x).toString();    }    public int getID(int x) {        return Integer.parseInt(this.id.get(x).toString());    }    public String getLicense(int x) {        return this.lic.get(x).toString();    }    public String getMake(int x) {        return this.make.get(x).toString();    }    public boolean getMeasurementUnits(int x) {        boolean y = true;        if (this.meas.get(x).toString().equalsIgnoreCase("M"))            y = false;        return y;    }    public String getModel(int x) {        return this.mod.get(x).toString();    }    public String getName(int x) {        return this.name.get(x).toString();    }    public float getPurchaseCost(int x) {        return Float.parseFloat(this.p_tot.get(x).toString());    }    public String getPurchaseDate(int x) {        return this.p_date.get(x).toString();    }    public int getPurchaseOdometer(int x) {        return Integer.parseInt(this.p_odo.get(x).toString());    }    public int getPurchaseVendorID(int x) {        return Integer.parseInt(this.p_ven.get(x).toString());    }    public String getVIN(int x) {        return this.vin.get(x).toString();    }    public int getYear(int x) {        return Integer.parseInt(this.year.get(x).toString());    }    public int indexOf(int ID) {        int y = -1;        for (int i=0; i<this.size(); i++)            if (this.id.get(i).toString().equalsIgnoreCase(String.valueOf(ID)))                y = i;        return y;    }    public int indexOf(String Name) {        int y = -1;        for (int i=0; i<this.size(); i++)            if (this.getName(i).equals(Name))                y = i;        return y;    }    public void insertRecord(int ID, String Name, int Year, String Make, String Model, String VIN, String License, String PurchaseDate, int PurchaseOdometer, int PurchaseVendorID, float PurchaseTotal, String Comment, String Active, String Measurement){        if (ID==-1) {            ID = 0;            while (this.indexOf(ID)!=-1)                ID++;        }        int i = 0;        if (Active.equalsIgnoreCase("F"))            while ((i<this.size()) && (this.getActive(i)))                i++;        while ((i<this.size()) && (this.getName(i).compareToIgnoreCase(Name)<0))            i++;        if ((i==this.size()) && (ID > -1))            this.addRecord(ID, Name, Year, Make, Model, VIN, License, PurchaseDate, PurchaseOdometer, PurchaseVendorID, PurchaseTotal, Comment, Active, Measurement);        else            if (!this.getName(i).equals(Name)) {                this.id.insertElementAt(new Integer(ID), i);                this.name.insertElementAt(new String(Name), i);                this.year.insertElementAt(new Integer(Year), i);                this.make.insertElementAt(new String(Make), i);                this.mod.insertElementAt(new String(Model), i);                this.vin.insertElementAt(new String(VIN), i);                this.lic.insertElementAt(new String(License), i);                this.p_date.insertElementAt(new String(PurchaseDate), i);                this.p_odo.insertElementAt(new Integer(PurchaseOdometer), i);                this.p_ven.insertElementAt(new Integer(PurchaseVendorID), i);                this.p_tot.insertElementAt(new Float(PurchaseTotal), i);                this.com.insertElementAt(new String(Comment), i);                this.act.insertElementAt(new String(Active), i);                this.meas.insertElementAt(new String(Measurement), i);            }    }    public int size() {        return this.id.size();    }}

⌨️ 快捷键说明

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