Created
June 20, 2020 09:23
-
-
Save javabuddy/ff9c0812816a0765b3c3fbb19f401014 to your computer and use it in GitHub Desktop.
Code for Book class in Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Book { | |
private final String name; | |
private final double price;public Star(String name, double price) { | |
this.name = name; | |
this.price = price; | |
} | |
@Override | |
public int hashCode() { | |
int hash = 7; | |
hash = 23 * hash + Objects.hashCode(this.name); | |
return hash; | |
} | |
@Override | |
public boolean equals(Object obj) { | |
if (obj == null) { | |
return false; | |
}if (getClass() != obj.getClass()) { | |
return false; | |
}final Test other = (Test) obj;if (!Objects.equals(this.name, other.name)) { | |
return false; | |
}if (Double.doubleToLongBits(this.price) != Double.doubleToLongBits(other.price)) { | |
return false; | |
} | |
return true; | |
} | |
@Override | |
public String toString() { | |
return "Test{" + "name=" + name + ", price=" + price + '}'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment