1
Hello people my question is that I am trying to receive by parameter an array of objects of another class,for the class I want to put the array by parameter.
Classes are : Route and Costs
I have to receive by parameter an array of objects of the type Route, to be able to calculate. Here is the code :
Class Route :
public class Percurso {
private double kmPercorrida;
private double valorCombustivel;
private double valorPedagio;
public Percurso() {
this(0,0,0);
}
public Percurso(double kmPercorrida, double valorCombustivel,
double valorPedagio) {
this.kmPercorrida = kmPercorrida;
this.valorCombustivel = valorCombustivel;
this.valorPedagio = valorPedagio;
}
Class Costs :
public class Custos {
public String calcularViagem(Percurso [] p ) {
return "";
}
}
In part Route [] p,need to pass the array of the Path object, kmPercorrida,valorCombustivel,valorPedagio.
OBS : In Return I only left so that no problems appear,.
How can I do that? If anyone knows please help me. And excuse me if the format of the post is wrong,I’m new here on the forum. I’ve also read how to make a decent post,but still any mistake,.
I did not understand what your doubt, it seems to be all right, although in a real code it would be a mistake to have monetary value as
double
.– Maniero
My question is that I want through this array to put the variables of the other class (Path) to be able to return later. 'Cause that’s what exercise calls for.
– Falion