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

Initial commit

parents
No related merge requests found
**/target/
/target/
*/target/*
.classpath
.project
.settings
# Package Files #
*.jar
*.war
*.ear
*.iml
*.idea
\ No newline at end of file
pom.xml 0 → 100644
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>koz01.java2</groupId>
<artifactId>lab04</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>15</maven.compiler.source>
<maven.compiler.target>15</maven.compiler.target>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>15.0.1</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>15.0.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.5.2</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-engine -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.5.2</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-params -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>5.5.2</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
package koz01.java2.lab04;
import javafx.scene.paint.Color;
public class ColorPoint extends Point {
private Color color;
public ColorPoint(double x, double y, Color color) {
super(x, y);
this.color = color;
}
}
package koz01.java2.lab04;
public class NutritionFacts {
private final int servingSize;// (mL)required
private final int servings;// (per container) required
private final int calories;// (per serving)optional
private final int fat;// (g/serving)optional
private final int sodium;// (mg/serving)optional
private final int carbohydrate; // (g/serving) optional
public NutritionFacts(int servingSize, int servings) {
this(servingSize, servings, 0);
}
public NutritionFacts(int servingSize, int servings, int calories) {
this(servingSize, servings, calories, 0);
}
public NutritionFacts(int servingSize, int servings, int calories, int fat) {
this(servingSize, servings, calories, fat, 0);
}
public NutritionFacts(int servingSize, int servings, int calories, int fat, int sodium) {
this(servingSize, servings, calories, fat, sodium, 0);
}
public NutritionFacts(int servingSize, int servings, int calories, int fat, int sodium, int carbohydrate) {
this.servingSize = servingSize;
this.servings = servings;
this.calories = calories;
this.fat = fat;
this.sodium = sodium;
this.carbohydrate = carbohydrate;
}
}
package koz01.java2.lab04;
public class Point {
private double x;
private double y;
public Point(double x, double y) {
this.x = x;
this.y = y;
}
}
module koz01.java2.lab04 {
requires transitive javafx.controls;
requires javafx.fxml;
opens koz01.java2.lab04 to javafx.fxml;
exports koz01.java2.lab04;
}
\ No newline at end of file
/* JavaFX CSS - Leave this comment until you have at least create one rule which uses -fx-Property */
\ No newline at end of file
package koz01.java2.lab04;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
import javafx.scene.paint.Color;
class TestEquals {
@Test
void testRelfexity() {
Point p1 = new Point(1,2);
assertTrue(p1.equals(p1));
}
@Test
void testSymmetry() {
Point p1 = new Point(1,2);
Point p2 = new Point(1,2);
Point p3 = new ColorPoint(1,1, Color.AZURE);
assertTrue(p1.equals(p2));
assertTrue(p2.equals(p1));
assertFalse(p1.equals(p3));
assertFalse(p3.equals(p1));
}
@Test
void testTransitivity() {
Point p1 = new ColorPoint(1,2,Color.CYAN);
Point p2 = new Point(1,2);
Point p3 = new ColorPoint(1,1, Color.AZURE);
assertFalse(p1.equals(p2));
assertFalse(p2.equals(p3));
assertFalse(p1.equals(p3));
}
@Test
void testLiskovPrinciple() {
Point p1 = new ColorPoint(1,2,Color.CYAN);
Point p2 = new ColorPoint(1,2, Color.CYAN) {
@Override
public String toString() {
return "Moje barva";
}
};
assertTrue(p1.equals(p2));
}
}
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