In this code, what I need is to compare the movie string to the attribute of all the objects in the Movie class, and if it finds it returning a Boolean, but somehow it does not, can you help me and see what is wrong? .
Thanks
public class Pelicula{
private String pelicula;
public Pelicula(int idPelicula, String pelicula) throws Exception{
super();
this.idPelicula = idPelicula;
this.setPelicula(pelicula);
}
public void setPelicula(String pelicula) throws Exception
{
boolean verificar = verificarPelicula(pelicula);
if (verificar == false) throw new Exception("Error: Pelicula existente");
this.pelicula=pelicula;
}
public boolean verificarPelicula(String pelicula)
{
List<Pelicula> listado = new ArrayList<>(); //intente con new ArrayList<Pelicula>
for(int cantPel = 0 ; cantPel <listado.size();cantPel++)
{
if (pelicula.equals(listado.get(cantPel).pelicula))//tambien intente con .getPelicula()
{
return false;
}
}
return true;
}
public String getPelicula(){
return pelicula;
}
}