1
I need to add the methods get for a ArrayList
, I tried with commas to separate, but it doesn’t work, I can only add if one is under the other, which is not good for me. I tried to create the ArrayList
of the kind of class I want to pull, but he calls the builders, which also would not serve.
The mistake is:
(current and formal Arguments lists differ in length)
Along with this above lists all means to add items in the list with the same error.
To ArrayList
need to store class objects CaixaLapis
who basically are gets and sets.
package prj_interdisciplinar;
//importar listas no Java
import java.util.ArrayList;
public class Pedido implements Manipulacao{
private Data data = new Data(1, 1, 2001);
private Cliente cliente = new Cliente("semnome", "semcpf", "semtel");
private float totalpedido;
private ArrayList cxlapis = new ArrayList();
private ArrayList papel = new ArrayList();
private ArrayList caderno = new ArrayList();
//construtor sem parametros
public Pedido(){
}
//Teste com ArrayList fora do método cadastro
public void adicionaCaixaLapis(){
CaixaLapis cxl = new CaixaLapis();
cxlapis.add(cxl.getQuantidade(), cxl.isColorido(), cxl.getMarca(), cxl.getValor());
}
void imprimeLista() {
for(int i = 0; i<cxlapis.size(); i++){
System.out.println(cxlapis.get(i));
}
}
/**
* @return the totalpedido
*/
public float getTotalpedido() {
return totalpedido;
}
/**
* @param totalpedido the totalpedido to set
*/
public void setTotalpedido(float totalpedido) {
this.totalpedido = totalpedido;
}
//calcular pedido
public void calculaTotalPedido(){
totalpedido = 0;
}
//chamada manipulacao
@Override
public boolean cadastro(){
imprimeLista();
return true;
}
@Override
public String consulta(){
return "texto";
}
}
Instead of
add
, would not beaddAll
?– Gustavo Sampaio
I tried with addAll, but the error informs that none of the add methods works because they differ in size, something like, I will try to play the error there in the post.
– Bruno Melo
In this case, do those functions return different values? That is,
getQuantidade()
,isColorido()
,getMarca()
andgetValor()
return values of different types?– Gustavo Sampaio
int, Boolean, String and float are the values, the idea would store side by side to print the line with information or at least display them side by side
– Bruno Melo
@Brunomelo Did the answer solve your question? Do you think you can accept it? See [tour] if you don’t know how to do it. This would help a lot to indicate that the solution was useful to you. You can also vote on any question or answer you find useful on the entire site
– Maniero