Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created September 2, 2019 17:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/b8822b86f27b29aeb3f405191bf7aea2 to your computer and use it in GitHub Desktop.
Save parzibyte/b8822b86f27b29aeb3f405191bf7aea2 to your computer and use it in GitHub Desktop.
class Producto {
private String codigo, nombre;
private float precio;
public Producto() {
}
public Producto(String codigo, String nombre, float precio) {
this.codigo = codigo;
this.nombre = nombre;
this.precio = precio;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Producto producto = (Producto) o;
return Float.compare(producto.precio, precio) == 0 &&
codigo.equals(producto.codigo)
&& nombre.equals(producto.nombre);
}
@Override
public int hashCode() {
return Objects.hash(codigo, nombre, precio);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment