I have a doubt that in the airplane class create an arrangement that has maximum capacity passengers being different classes [closed]

1

Avion

public class Avion{
private int matricula;
private String modelo;
private String marca;  

public Avion(){
}
public Avion(int matricula, String modelo, String marca ){
    this.matricula=matricula;
    this.modelo=modelo;
    this.marca=marca;
}
public void setMatricula(int matricula){
    this.matricula=matricula;
}
public int getMatricula(){
    return matricula;
}
public void setModelo(String modelo){
    this.modelo=modelo;
}
public String getModelo(){
    return modelo;
}
public void setMarca(String marca){
    this.marca=marca;
}
public String getMarca(){
    return marca;
}


public String toString(){
    return this.getMarca()+" "+this.getModelo()+" "+this.getMatricula()+" "+this.getModelo();
}
}

Passenger

public class Pasajero{

public String rut;
public int edad;
public String nombre;
public String apellidoPaterno;
public String apellidoMaterno;


public Pasajero(){
}
public Pasajero (String rut, int edad, String nombre, String apellidoPaterno, String apellidoMaterno){
    this.rut=rut;
    this.edad=edad;
    this.nombre=nombre;
    this.apellidoPaterno=apellidoPaterno;
    this.apellidoMaterno=apellidoMaterno;
}    

public void setRut(String rut) {
    this.rut = rut;
}
public String getRut(){
    return rut;
}
public void setEdad (int edad){
    this.edad=edad;
}
public int getEdad(){
    return edad;
}
public void setNombre(String nombre){
    this.nombre=nombre;
}
public String getNombre(){
    return nombre;
}
public void setApellidoPaterno(String apellidoPaterno){
    this.apellidoPaterno=apellidoPaterno;
}
public String getApellidoPaterno(){
    return apellidoPaterno;
}
public void setApellidoMaterno (String apellidoMaterno){
    this.apellidoMaterno=apellidoMaterno;
}
public String getApellidoMaterno(){
    return apellidoMaterno;
}
public String toString(){
    return this.getNombre()+" "+this.getApellidoPaterno()+" "+this.getApellidoMaterno()+" "+this.getEdad()+" "+this.getRut();
} 
}

The doubt is that I have my airplane class and I need to create an arrangement that tells me the maximum capacity of the plane but that this arrangement is filled with the passenger class and I do not know how to do it since they are different classes (I am using Bluej)

    
asked by Zealots 09.10.2017 в 03:15
source

1 answer

2

You have to add a couple of things to your airplane class:

You need to declare the passengers, for that you have enough to do:

Pasajero[] LosPasajeros;

This at the class level.

And then in the airplane builder, you will need a property that is the maximum number of passengers and do:

LosPasejeros = new Pasajeros[CantidadMaximaDePasajeros]

That way you'll have a passenger arrangement. You will also have to add to your avion class, a method to add passengers to this vector.

    
answered by 09.10.2017 в 03:44