Skip to content
Snippets Groups Projects
Verified Commit b27f786c authored by Jan Kožusznik's avatar Jan Kožusznik
Browse files

Use java 17.

Use simple implementation for equals.
parent a7b1e813
Branches master
No related merge requests found
......@@ -8,20 +8,10 @@
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>11</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>11</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api -->
<dependency>
<groupId>org.junit.jupiter</groupId>
......
package cz.jezek.lab11;
import java.util.Objects;
public class Player {
private String firstName;
......@@ -34,33 +36,18 @@ public class Player {
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((firstName == null) ? 0 : firstName.hashCode());
result = prime * result + ((lastName == null) ? 0 : lastName.hashCode());
return result;
return Objects.hash(firstName, lastName);
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Player other = (Player) obj;
if (firstName == null) {
if (other.firstName != null)
return false;
} else if (!firstName.equals(other.firstName))
return false;
if (lastName == null) {
if (other.lastName != null)
return false;
} else if (!lastName.equals(other.lastName))
return false;
return true;
if (obj instanceof Player other) {
return Objects.equals(firstName, other.firstName) && Objects.equals(lastName, other.lastName);
}
return false;
}
@Override
......
module cz.jezek.lab10 {
requires transitive javafx.controls;
requires javafx.fxml;
opens cz.jezek.lab11 to javafx.fxml;
exports cz.jezek.lab11;
}
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment