/*
 * 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 git;

import java.awt.CheckboxMenuItem;
import java.awt.Menu;
import java.util.ArrayList;

/**
 *
 * @author Fabio
 */
public class User {
    private int id = -1;
    private CheckboxMenuItem checkboxMenuItem =  null;
    private Menu menu = null;
    private String username = null;
    private boolean state = true;
    private ArrayList<Order> orders = null;
    
    public User(int id, String username, CheckboxMenuItem checkboxMenuItem){
        this.id = id;
        this.username = username;
        this.checkboxMenuItem = checkboxMenuItem;
        menu = new Menu(username);
        orders = new ArrayList<Order>();
    }
    
    public boolean getState(){
        return state;
    }
    
    public void setState(boolean state){
        this.state = state;
    }
    
    public Menu getMenu(){
        return menu;
    }
    
    public CheckboxMenuItem getCheckboxMenuItem(){
        return checkboxMenuItem;
    }
    
    public int getId(){
        return id;
    }
    
    public void refreshMenu(int[] ids, int[] actions){
        if(menu != null){
            menu.removeAll();
            orders.clear();
            for (int i=0; i<ids.length; i++) {
                Order order = new Order(ids[i], actions[i]);
                orders.add(order);
                menu.add(order.getMenuItem());
            }
        }
    }
    
    public ArrayList<Order> getOrders(){
        return orders;
    }
}
