Skip to content
Snippets Groups Projects
Commit 338989fe authored by jez04's avatar jez04
Browse files

feat: lab03 assigment

parent 3fe2e190
Branches master
No related merge requests found
Pipeline #2524 failed with stages
in 0 seconds
Showing
with 71 additions and 430 deletions
File moved
File moved
#!/bin/bash
cd java2-lab02-common-v1
mvn clean install
cd ../java2-lab02-db-v1
mvn clean install
cd ../java2-lab02-file-v1
mvn clean install
cd ../java2-lab02-v1
mvn clean package
java --module-path target/java2-lab02-v1-0.0.1-SNAPHOST.jar:target/libs -m cz.vsb.fei.java2.lab02_module/lab.gui.App
cd ..
# Eclipse
.classpath
.project
.settings/
# Intellij
.idea/
*.iml
*.iws
# Mac
.DS_Store
# Maven
log/
target/
<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>cz.vsb.fei.java2</groupId>
<artifactId>java2-lab02-common-v1</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>java2-lab02-common-v1</name>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>21</maven.compiler.release>
<JUnit.version>5.11.0</JUnit.version>
<log4j.version>2.23.1</log4j.version>
<lombok.version>1.18.34</lombok.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>${JUnit.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.0</version>
</plugin>
</plugins>
</build>
</project>
module cz.vsb.fei.java2.lab02.common_module {
requires static lombok;
requires org.apache.logging.log4j;
exports cz.vsb.fei.java2.lab02.common;
}
\ No newline at end of file
package cz.vsb.fei.java2.lab01;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
/**
* Unit test for simple App.
*/
class AppTest {
/**
* Rigorous Test :-)
*/
@Test
void shouldAnswerWithTrue() {
assertTrue(true);
}
}
# Eclipse
.classpath
.project
.settings/
# Intellij
.idea/
*.iml
*.iws
# Mac
.DS_Store
# Maven
log/
target/
<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>cz.vsb.fei.java2</groupId>
<artifactId>java2-lab02-db-v1</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>java2-lab02-db-v1</name>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>21</maven.compiler.release>
<JUnit.version>5.11.0</JUnit.version>
<log4j.version>2.23.1</log4j.version>
<lombok.version>1.18.34</lombok.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>${JUnit.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>cz.vsb.fei.java2</groupId>
<artifactId>java2-lab02-common-v1</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>2.3.232</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.0</version>
</plugin>
</plugins>
</build>
</project>
import cz.vsb.fei.java2.lab02.common.ScoreStorageInterface;
import cz.vsb.fei.java2.lab02.db.DbConnector;
module cz.vsb.fei.java2.lab02.db_module {
requires static lombok;
requires org.apache.logging.log4j;
requires transitive cz.vsb.fei.java2.lab02.common_module;
requires java.sql;
exports cz.vsb.fei.java2.lab02.db;
provides ScoreStorageInterface with cz.vsb.fei.java2.lab02.db.DbConnector;
}
\ No newline at end of file
<Configuration>
<Appenders>
<Console name="Console">
<PatternLayout
pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n" />
</Console>
</Appenders>
<Loggers>
<Root level="info">
<AppenderRef ref="Console"></AppenderRef>
</Root>
</Loggers>
</Configuration>
# Eclipse
.classpath
.project
.settings/
# Intellij
.idea/
*.iml
*.iws
# Mac
.DS_Store
# Maven
log/
target/
<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>cz.vsb.fei.java2</groupId>
<artifactId>java2-lab02-file-v1</artifactId>
<version>1.0-SNAPSHOT</version>
<name>java2-lab02-file-v1</name>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>21</maven.compiler.release>
<JUnit.version>5.11.0</JUnit.version>
<log4j.version>2.23.1</log4j.version>
<lombok.version>1.18.34</lombok.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>${JUnit.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>cz.vsb.fei.java2</groupId>
<artifactId>java2-lab02-common-v1</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.0</version>
</plugin>
</plugins>
</build>
</project>
import cz.vsb.fei.java2.lab02.common.ScoreStorageInterface;
module cz.vsb.fei.file_module {
requires static lombok;
requires org.apache.logging.log4j;
requires transitive cz.vsb.fei.java2.lab02.common_module;
exports cz.vsb.fei.file;
provides ScoreStorageInterface with cz.vsb.fei.file.FileStorage;
}
\ No newline at end of file
package lab;
import java.util.ArrayList;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.Random;
import java.util.ServiceLoader;
import cz.vsb.fei.java2.lab02.common.ScoreStorageInterface;
import javafx.scene.control.Alert;
import javafx.scene.control.ButtonType;
import javafx.stage.Modality;
import javafx.scene.control.Alert.AlertType;
public class ScoreStorageFactory {
private static ScoreStorageInterface instance;
private ScoreStorageFactory() {
/* hide public one constructor */
}
public static ScoreStorageInterface getInstance() {
if (instance == null) {
List<ScoreStorageInterface> availableImplementations = new ArrayList<>();
ServiceLoader.load(ScoreStorageInterface.class).forEach(availableImplementations::add);
if (availableImplementations.isEmpty()) {
throw new NoSuchElementException(
"Service loader did not find any implementation of interface ScoreStorageInterface.");
}
instance = availableImplementations.get(new Random().nextInt(availableImplementations.size()));
Alert info = new Alert(AlertType.INFORMATION,
String.format("Storage %s selected.", instance.getClass().getName()), ButtonType.OK);
info.initModality(Modality.WINDOW_MODAL);
info.showAndWait();
}
return instance;
}
}
......@@ -3,10 +3,10 @@
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>cz.vsb.fei.java2</groupId>
<artifactId>java2-lab02-v1</artifactId>
<artifactId>java2-lab03-v1</artifactId>
<version>0.0.1-SNAPHOST</version>
<name></name>
<name>java2-lab03-v1</name>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
......@@ -15,19 +15,10 @@
</properties>
<dependencies>
<dependency>
<groupId>cz.vsb.fei.java2</groupId>
<artifactId>java2-lab02-common-v1</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>cz.vsb.fei.java2</groupId>
<artifactId>java2-lab02-db-v1</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>cz.vsb.fei.java2</groupId>
<artifactId>java2-lab02-file-v1</artifactId>
<version>1.0-SNAPSHOT</version>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>2.3.232</version>
<scope>runtime</scope>
</dependency>
<dependency>
......
#!/bin/bash
cd java2-lab02-v1
java --module-path target/java2-lab02-v1-0.0.1-SNAPHOST.jar:target/libs -m cz.vsb.fei.java2.lab02_module/lab.gui.App
cd ..
File moved
package lab;
import lab.storage.DbConnector;
import lab.storage.ScoreStorageInterface;
public class Setting {
private static Setting instance;
private ScoreStorageInterface scoreStorageInterface = new DbConnector();
private double gravity = 9.81;
private double normalBulletSpeed = 30;
private int numberOfUfos = 3;
private double ufoMinPercentageHeight = 0.3;
private double ufoMinSpeed = 70;
private double ufoMaxSpeed = 150;
private double bulletMinSpeed = 30;
private double bulletMaxSpeed = 300;
public static void configure(Setting setting) {
instance = setting;
}
public static Setting getInstance() {
return instance;
}
public double getGravity() {
return gravity;
}
public double getNormalBulletSpeed() {
return normalBulletSpeed;
}
public int getNumberOfUfos() {
return numberOfUfos;
}
public ScoreStorageInterface getScoreStorageInterface() {
return scoreStorageInterface;
}
public double getUfoMinPercentageHeight() {
return ufoMinPercentageHeight;
}
public double getUfoMinSpeed() {
return ufoMinSpeed;
}
public double getUfoMaxSpeed() {
return ufoMaxSpeed;
}
public double getBulletMinSpeed() {
return bulletMinSpeed;
}
public double getBulletMaxSpeed() {
return bulletMaxSpeed;
}
}
package cz.vsb.fei.java2.lab02.common;
package lab.data;
import java.util.Random;
......
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