/*
 * Decompiled with CFR 0_123.
 */
package com.zakscode.FormulaManager;

import com.zakscode.FormulaManager.Main;
import com.zakscode.FormulaManager.TableArray;
import java.io.Serializable;
import java.text.DecimalFormat;
import java.util.Calendar;
import java.util.Date;

public class Component
implements Serializable,
TableArray {
    private static final long serialVersionUID = -2154735157565376110L;
    private String partNum;
    private String vendor;
    private String description;
    private double cost;
    private Date date;

    public Component(String partNum, String vendor, String description, double cost) {
        this.partNum = partNum;
        this.vendor = vendor;
        this.description = description;
        this.cost = cost;
        this.date = Calendar.getInstance().getTime();
    }

    public String getPartNum() {
        return this.partNum;
    }

    public String getVendor() {
        return this.vendor;
    }

    public String getDescription() {
        return this.description;
    }

    public double getCost() {
        DecimalFormat df = new DecimalFormat("0.00");
        if (Main.metric) {
            return Double.parseDouble(df.format(this.cost));
        }
        return Double.parseDouble(df.format(this.cost / 2.2));
    }

    public Date getDate() {
        return this.date;
    }

    public void setPartNum(String partNum) {
        this.partNum = partNum;
        this.date = Calendar.getInstance().getTime();
    }

    public void setVendor(String vendor) {
        this.vendor = vendor;
        this.date = Calendar.getInstance().getTime();
    }

    public void setDescription(String description) {
        this.description = description;
        this.date = Calendar.getInstance().getTime();
    }

    public void setCost(double cost) {
        this.cost = Main.metric ? cost : cost * 2.2046;
        this.date = Calendar.getInstance().getTime();
    }

    @Override
    public Object[] toArray() {
        DecimalFormat df = new DecimalFormat("$0.00  ");
        return new Object[]{this.partNum, this.vendor, this.description, df.format(this.getCost()), this.date};
    }

    public String toString() {
        return this.partNum;
    }
}

