package net.tinsae.shop;

import java.sql.*;
import java.util.*;


public class Item{
    private int id;
    private String name, description;
    private float price;

    public Item(){}

    public Item(String name, String description, float price){
        this.name = name;
        this.description=description;
        this.price = price;
    }

    public Item(int id, String name, String description, float price){
        this(name,description,price);
        this.id = id;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public float getPrice() {
        return price;
    }

    public void setPrice(float price) {
        this.price = price;
    }

    public static Item createItem(int id, String name, String description, float price) {
        if(name.isEmpty() || description.isEmpty() || price == 0.0){
            throw new InvalidItemException("Invalid Item properties");
        }else{
            return new Item(id,name,description,price);
        }
    }


}