Iae pessoas estou com algumas duvidass.se alguem poder me aajudar a entender
public class Avestruzes
{
private int tempos[];
// duvida aqui qual a real necessidade disso ?
// não poderia ser so .. int [ ] tempos = new int [10];
public Avestruzes(int tempos[])
{
this.tempos = tempos;
}
public int indicePrimeiroColocado()
{
int menorTempo = tempos[0];
int indiceMenorTempo = 0;
for (int i = 1; i < tempos.length; i++)
{
if (tempos[i] < menorTempo)
{
menorTempo = tempos[i];
indiceMenorTempo = i;
}
}
return indiceMenorTempo;
}
import javax.swing.*;
public class ex37
{
public static void main(String args[])
{
String aux;
int array[]= new int [15];
// obj se cria assim qdo tem construtor duvidaa ???
Avestruzes objAvestruzes;
for (int i = 0; i < array.length; i++)
{
//duvida essa String """ Avestruzes """ chama algooo ?
aux = JOptionPane.showInputDialog(null, " Informe tempo do Aveztruz do índice " + i, " Avestruzes " , JOptionPane.QUESTION_MESSAGE);
array[i]= Integer.parseInt(aux);
}
// duvida aquiiii ~;não entendii ..não poderia ser assim :
//NOmeDaclasse obj = new NOmeDaclasse ();
objAvestruzes = new Avestruzes(array);
// essa variavel aux armazena respostaa tambéem ?
aux = "Índice do Primeiro colocado: " + objAvestruzes.indicePrimeiroColocado() + "\n\n";
aux = aux + "Índice do Segundo colocado: " + objAvestruzes.indiceSegundoColocado() + "\n\n" ;
aux = aux + "Diferença entre o Primeiro e o Último: " + objAvestruzes.diferencaDoPrimeiroAteUltimo() + " segundos";