Tenho uma dúvida quanto a impressão do construtor Vet, quando uso o System.out.printf(vet[i]), ele não imprime os dados digitados, alguém pode auxiliar ?
@SuppressWarnings("null")
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
Locale.setDefault(Locale.US);
// LEITURA DE QUANTOS QUARTOS SERAM ALUGADOS PARA O "FOR"
System.out.printf("Quantos quartos serão alugados ? : ");
int n = sc.nextInt();
Pensao[] vet = new Pensao[10];
//CONSTRUTOR DOS VETORES - COM NOME , EMAIL E QUAL O QUARTO
for (int i=0;i<n;i++){
System.out.printf("Pedido: "+ (i+1) + "\n");
System.out.printf("NOME do Hospede : ");
String nome = sc.next();
sc.nextLine();
System.out.printf("e-mail do Hospede : ");
String email = sc.next();
sc.nextLine();
System.out.printf("Quarto desejado : ");
Integer quarto = sc.nextInt();
vet[i] = new Pensao(nome, email, quarto);
}
for ( int i=0;i<n;i++){
System.out.printf(vet[i]);
}
}
Você testou? Está usando alguma IDE (eclipse, netbeans, intellij)? Se sim, a própria IDE oferece recursos para criar um toString específico;
Mas, você sempre pode fazer
E assim por diante, para cada atributo do tal objeto.