0
package pkg2017ppfp09;
import ObjectManagement.ContainerOfObjects;
/**
*
* @author pf
*/
public class GestorDeReservas extends ContainerOfObjects{
private final int MAX_RESERVAS = 10;
private final Reserva[] Hist = new Reserva[10];
private Reserva[] reserva;
public GestorDeReservas(Reserva[] reserva) {
super(reserva);
this.reserva = new Reserva[MAX_RESERVAS];
}
public GestorDeReservas(Reserva[] reserva,int maxsize) {
super(reserva);
this.reserva = new Reserva[maxsize];
}
public boolean addObject(Reserva reserva) {
boolean i=false;
i=Verificar_reservas((Reserva) reserva);
if(i==true){
super.addObject(reserva);
//transferObj();
return true;
}else{
return false; //To change body of generated methods, choose Tools | Templates.
}
}
private Reserva[] transferObj(){
return (Reserva[])getAllObj();
}
private boolean Verificar_reservas(Reserva reserva){
Reserva temp = new Reserva();
temp = reserva;
for (Reserva reserva1 : this.reserva) {
if (reserva1 != null && reserva1.getAnimal().equals(temp.getAnimal()) && reserva1.getData().equals(temp.getData())) {
return false;
}
}
return true;
}
public boolean concluida(Reserva reserva){
Reserva temp = new Reserva();
temp = reserva;
for (Reserva reserva1 : this.reserva) {
if (reserva1.getAnimal().equals(temp.getAnimal()) && reserva1.getData().equals(temp.getData())) {
reserva1.setConluida(true);
return true;
}
}
return false;
}
public boolean Hist(Reserva[] hist){
for(int i=0;i<this.reserva.length;i++){
if(this.reserva[i].getConluida()==true){
hist[i]= this.reserva[i];
}
}
return true;
}
public void listNconcl(DATA data){
for (Reserva reserva1 : this.reserva) {
if (reserva1.getData() == data) {
System.out.println(reserva1.getAnimal().getANIMAL_NOME());
}
}
}
}
I wonder how to pass the array if possible in inherited to the reserves.
What is inherited?
– user28595
The inherited is basically the "Object" that comes from the superclass. But I have found a solution to my problem.
– pp fernandes