Fill a Class with an ArrayList of Objects of another kind

1

Basically I am designing a program for a restaurant (without stock), it is to render the programming subject. I request help :(

I have an Input class, another Plato class, and another Mesa class.

Objects of type Inputs are instantiated with their code and description. Plato class objects also have code and description, but they are also composed of an ArrayList. The Mesa class objects have their identifier number, and are composed of Plato collections. All my ArrayList (Inputs and Dishes) are stored in a separate class, called Rest (to prevent them from being lost).

But the Plato class has its own Input-type ArrayList, since each Plato instance can contain 1, or several objects of type .-

What is not coming out is to send through the graphical interface to the ArrayList to put inside the Plato class.

That is to say ... I managed to upload the list of supplies that I register in a ComboBox. What you would need is an option to choose several Inputs, and add them to the ArrayList of the Plato class. To then send that object of type Plate to its corresponding ArrayList, with the ArrayList that corresponds to it.

I explain?

That is, it would have an ArrayList that would contain Plato objects and each Plato has ArrayList objects.

I hope you understand ... Anything I edit or put the code.

    
asked by Lenz 04.08.2016 в 22:09
source

1 answer

0

Brief more questions please. It would be simpler to use the classes with this hierarchy:

Class main

Mesa mesa = new Mesa ();
Plato plato = new Plato ();
Plato plato1 = new Plato ();
Plato plato2 = new Plato ();
mesa.get (0).addPlato (plato);
mesa.get (0).addPlato (plato2);
mesa.get (0).addPlato (plato3);

Class table: Add the functionality of the variable plate the get, set and add.

//declaración variable
private List <Plato> platos;
//instancia
plato = new ArrayList  <Plato>();
//función de add
public void addPlato (Plato arg){
   this.platos.add (arg);
}

I leave this type of structure for you to use a simple and easy way to work with lists.

Greetings and I hope it will help you

    
answered by 11.08.2016 / 04:13
source