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 @@ ...@@ -8,20 +8,10 @@
<packaging>jar</packaging> <packaging>jar</packaging>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source> <maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target> <maven.compiler.target>17</maven.compiler.target>
</properties> </properties>
<dependencies> <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 --> <!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api -->
<dependency> <dependency>
<groupId>org.junit.jupiter</groupId> <groupId>org.junit.jupiter</groupId>
......
package cz.jezek.lab11; package cz.jezek.lab11;
import java.util.Objects;
public class Player { public class Player {
private String firstName; private String firstName;
...@@ -34,33 +36,18 @@ public class Player { ...@@ -34,33 +36,18 @@ public class Player {
@Override @Override
public int hashCode() { public int hashCode() {
final int prime = 31; return Objects.hash(firstName, lastName);
int result = 1;
result = prime * result + ((firstName == null) ? 0 : firstName.hashCode());
result = prime * result + ((lastName == null) ? 0 : lastName.hashCode());
return result;
} }
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (this == obj) if (this == obj)
return true; return true;
if (obj == null) if (obj instanceof Player other) {
return false; return Objects.equals(firstName, other.firstName) && Objects.equals(lastName, other.lastName);
if (getClass() != obj.getClass()) }
return false; 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;
} }
@Override @Override
......
module cz.jezek.lab10 { module cz.jezek.lab10 {
requires transitive javafx.controls;
requires javafx.fxml;
opens cz.jezek.lab11 to javafx.fxml;
exports cz.jezek.lab11; 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