package Model;

import java.io.Serializable;
/**
 *<b>Article est la classe représentant un article géré par notre application</b>
 * <p>
 * Un article est caractérisé par les informations suivantes :
 * <ul>
 * <li>Son type</li>
 * <li>Sa description</li>
 * <li>Son code</li>
 * <li>Sa nomenclature</li>
 * <li>Son prix</li>
 * </ul>
 * </p>
 *
 * @author Administrator
 *
 */
public class Article implements Serializable
{
	private static final long serialVersionUID = -195895566248116109L;
	
	private String type;
	private String description;
	private String code;
	@SuppressWarnings("unused")
	private Nomenclature nomenclature;
	
	private float prix;
	

	public Article(String type,String description,float prix) 
	{
		this.type = type;
		this.description = description;
		this.prix = prix;
		nomenclature = new Nomenclature();
		code();
		
	}
	
	public void code()
	{
		String fin = "";
		int code = (int) (10000*(Math.random()));
		
		fin = Integer.toString(code);
		this.code = this.description.substring(0,2) + fin;
	}

	public String getType() 
	{
		return type;
	}


	public void setType(String type) 
	{
		this.type = type;
	}


	public String getDescription() 
	{
		return description;
	}


	public void setDescription(String description) 
	{
		this.description = description;
	}


	public String getCode() 
	{
		return code;
	}


	public void setCode(String code) 
	{
		this.code = code;
	}


	public float getPrix() 
	{
		return prix;
	}


	public void setPrix(float prix) 
	{
		this.prix = prix;
	}
	
	public String toString()
	{
		String art ="Il s'agit de: " + this.description + " de type " + this.type + "coutant " + this.prix + "et ayant pour code: " + this.code;
		return art;
	}
}
