Error when programming in android studio

0

I do not know why it tells me that the Método Lugar() can not be applied in the class Lugar for its parameters that we passed to it.

package com.example.mislugares;

public class Lugar {
public String getNombre() {
    return nombre;
}

public void setNombre(String nombre) {
    this.nombre = nombre;
}

public String getDireccion() {
    return direccion;
}

public void setDireccion(String direccion) {
    this.direccion = direccion;
}

public GeoPunto getPosicion() {
    return posicion;
}

public void setPosicion(GeoPunto posicion) {
    this.posicion = posicion;
}

public String getFoto() {
    return foto;
}

public void setFoto(String foto) {
    this.foto = foto;
}

public int getTelefono() {
    return telefono;
}

public void setTelefono(int telefono) {
    this.telefono = telefono;
}

public String getUrl() {
    return url;
}

public void setUrl(String url) {
    this.url = url;
}

public String getComentario() {
    return comentario;
}

public void setComentario(String comentario) {
    this.comentario = comentario;
}

public long getFecha() {
    return fecha;
}

public void setFecha(long fecha) {
    this.fecha = fecha;
}
public TipoLugar getTipo() {
    return tipo;
}

public void setTipo(TipoLugar tipo) {
    this.tipo = tipo;
}
private String nombre;
private String direccion;
private GeoPunto posicion;
private String foto;
private int telefono;
private String url;
private String comentario;
private TipoLugar tipo;

@Override
public String toString() {
    return "Lugar{" +
            "nombre='" + nombre + '\'' +
            ", direccion='" + direccion + '\'' +
            ", posicion=" + posicion +
            ", foto='" + foto + '\'' +
            ", telefono=" + telefono +
            ", url='" + url + '\'' +
            ", comentario='" + comentario + '\'' +
            ", tipo=" + tipo +
            ", fecha=" + fecha +
            '}';
}

private long fecha;



public Lugar(String nombre, String direccion, double longitud, double latitud, int telefono, String url, String comentario, int valoracion, TipoLugar tipo)
{
    fecha = System.currentTimeMillis();
    posicion = new GeoPunto(0, 0);
   tipo = TipoLugar.OTROS;


}
}

And here where the error occurs:

    public int nuevo() {                 
    Lugar lugar = new Lugar();       
    vectorLugares.add(lugar);        
    return vectorLugares.size()-1;   
}                                    
    
asked by Mariopenguin 14.09.2017 в 01:28
source

1 answer

3

I see that you are calling the constructor without paramenters, and for what is in the code you defined it with parameters. You should define a constructor without parameters.

In the class:

public class Lugar{
//....
    public Lugar(){}
//.....
}

At first glance there is the error. I tried it on NetBeans with java.

    
answered by 14.09.2017 в 02:00