/*
 * Copyright (C) 2022 - Florindo Smilari (spherIC)
 */
package ch.spherIC.recurvebowsight.model.impl;

import java.text.DecimalFormat;
import java.util.Objects;

import ch.spherIC.recurvebowsight.model.IArrow;


/**
 * @author F. Smilari
 */
public class Arrow implements IArrow {

    private static final DecimalFormat DF = new DecimalFormat("0.###");

    private long id;
    private String manufacturer;
    private String model;
    private Double diameter;
    private Double weight;
    private Double cw;
    private Double v0;
    private String colors;

    /**
     * Konstruktor.
     *
     * @param id
     * @param manufacturer
     * @param model
     * @param diameter
     * @param weight
     * @param cw
     * @param v0
     * @param colors
     */
    public Arrow(final long id, final String manufacturer, final String model, final Double diameter,
                 final Double weight, final Double cw, final Double v0, String colors) {
        super();
        this.id = id;
        this.manufacturer = manufacturer;
        this.model = model;
        this.diameter = diameter;
        this.weight = weight;
        this.cw = cw;
        this.v0 = v0;
        this.colors = colors;
    }

    /**
     * @return the id
     */
    @Override
    public long getId() {
        return this.id;
    }

    /**
     * @param id the id to set
     */
    @Override
    public void setId(final long id) {
        this.id = id;
    }

    /**
     * @return the manufacturer
     */
    @Override
    public String getManufacturer() {
        return this.manufacturer;
    }

    /**
     * @param maufacturer the maufacturer to set
     */
    @Override
    public void setManufacturer(final String maufacturer) {
        this.manufacturer = maufacturer;
    }

    /**
     * @return the model
     */
    @Override
    public String getModel() {
        return this.model;
    }

    /**
     * @param model the model to set
     */
    @Override
    public void setModel(final String model) {
        this.model = model;
    }

    @Override
    public Double getDiameter() {
        return this.diameter;
    }

    /**
     * @param diameter the diameter to set
     */
    @Override
    public void setDiameter(Double diameter) {
        this.diameter = diameter;
    }

    @Override
    public Double getWeight() {
        return this.weight;
    }

    /**
     * @param weight the weight to set
     */
    @Override
    public void setWeight(Double weight) {
        this.weight = weight;
    }

    @Override
    public Double getCw() {
        return this.cw;
    }

    /**
     * @param cw the cw to set
     */
    @Override
    public void setCw(Double cw) {
        this.cw = cw;
    }

    @Override
    public Double getV0() {
        return this.v0;
    }

    /**
     * @param v0 the v0 to set
     */
    @Override
    public void setV0(Double v0) {
        this.v0 = v0;
    }

    @Override
    public String getColors() {
        return this.colors;
    }

    /**
     * @param colors the colors to set
     */
    @Override
    public void setColors(String colors) {
        this.colors = colors;
    }

    @Override
    public String toString() {
        if (this.id == -999) {
            return getManufacturer();
        }
        return getManufacturer() + " " + getModel() + " (" + getColors() + ")";
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        Arrow arrow = (Arrow) o;
        return id == arrow.id && manufacturer.equals(arrow.manufacturer) && model.equals(arrow.model);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, manufacturer, model);
    }
}
