/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package object.itemmanager;

import java.util.Arrays;

/**
 *
 * @author Administrator
 */
public class ItemApp {

    private String id;
    private String name;
    private String[] listOption;
    private Size[] listSize;
    private boolean active;

    public ItemApp() {
    }

    public ItemApp(String id, String name, boolean active) {
        this.id = id;
        this.name = name;
        this.active = active;
    }

    public String getId() {
        return id;
    }

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

    public String getName() {
        return name;
    }

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

    public String[] getListOption() {
        return listOption;
    }

    public void setListOption(String[] listOption) {
        this.listOption = listOption;
    }

    public Size[] getListSize() {
        return listSize;
    }

    public void setListSize(Size[] listSize) {
        this.listSize = listSize;
    }

    public boolean isActive() {
        return active;
    }

    public void setActive(boolean active) {
        this.active = active;
    }

    public String[] toArray() {
        return new String[]{id, name, sizeToString(), optionToString(), active ? "Kích hoạt" : "Ẩn"};
    }

    @Override
    public String toString() {
        return "ItemApp{" + "id=" + id + ", name=" + name + ", listOption=" + Arrays.toString(listOption) + ", listSize=" + Arrays.toString(listSize) + ", active=" + active + '}';
    }

    public String sizeToString() {
        if (listSize != null) {
            StringBuilder sb = new StringBuilder();
            for (Size size : listSize) {
                sb.append(size.getName()).append("[").append(size.getPercent()).append("]|");
            }
            return sb.toString().substring(0, sb.length() - 1);
        }
        return "";
    }

    public String optionToString() {
        if (listOption != null) {
            StringBuilder sb = new StringBuilder();

            for (String option : listOption) {
                sb.append(option).append("|");
            }
            return sb.toString().substring(0, sb.length() - 1);
        }
        return "";
    }
}
