Skip to content

Add files via upload #458

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions Guess The Number Game/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>br.com.exemplo</groupId>
<artifactId>meu-projeto</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.10.2</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.2.5</version>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package learningspace.swtest.examples;

public class GameLogic {
public String checkGuess(int guess, int correctNumber) {
if (guess == correctNumber) {
return "Correct!";
} else if (guess < correctNumber) {
return "Too low!";
} else {
return "Too high!";
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class GuessTheNumberGame extends Application {
private int targetNumber = (int) (Math.random() * 100) + 1;
private int numberOfTries = 0;

public static void main(String[] args) {
launch(args);
}

@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("Guess the Number Game");

Label titleLabel = new Label("Guess the Number (1-100)");
TextField guessInput = new TextField();
guessInput.setId("guessInput"); // ID adicionado
Label messageLabel = new Label();
messageLabel.setId("messageLabel"); // ID adicionado
VBox vbox = new VBox(titleLabel, guessInput, messageLabel);

guessInput.setOnAction(e -> {
try {
int userGuess = Integer.parseInt(guessInput.getText());
numberOfTries++;
if (userGuess < targetNumber) {
messageLabel.setText("Try higher.");
} else if (userGuess > targetNumber) {
messageLabel.setText("Try lower.");
} else {
messageLabel.setText("Congratulations! You guessed the number in " + numberOfTries + " tries.");
}
guessInput.clear();
} catch (NumberFormatException ex) {
messageLabel.setText("Invalid input. Enter a number.");
}
});

Scene scene = new Scene(vbox, 300, 150);
primaryStage.setScene(scene);
primaryStage.show();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import learningspace.swtest.examples.GameLogic;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;

public class GameLogicTest {

@Test
void testCorrectGuess() {
GameLogic logic = new GameLogic();
assertEquals("Correct!", logic.checkGuess(7, 7));
}

@Test
void testTooLow() {
GameLogic logic = new GameLogic();
assertEquals("Too low!", logic.checkGuess(5, 7));
}

@Test
void testTooHigh() {
GameLogic logic = new GameLogic();
assertEquals("Too high!", logic.checkGuess(9, 7));
}
}
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
GuessTheNumberGame.class
learningspace\swtest\examples\GameLogic.class
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
C:\Users\anell\Downloads\trabalho\Guess the number\src\main\java\learningspace\swtest\examples\GameLogic.java
C:\Users\anell\Downloads\trabalho\Guess the number\src\main\java\learningspace\swtest\examples\GuessTheNumberGame.java
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GameLogicTest.class
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
C:\Users\anell\Downloads\trabalho\Guess the number\src\test\java\learningspace\swtest\examples\GameLogicTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-------------------------------------------------------------------------------
Test set: GameLogicTest
-------------------------------------------------------------------------------
Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.082 s -- in GameLogicTest
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuite xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://maven.apache.org/surefire/maven-surefire-plugin/xsd/surefire-test-report-3.0.xsd" version="3.0" name="GameLogicTest" time="0.082" tests="3" errors="0" skipped="0" failures="0">
<properties>
<property name="sun.desktop" value="windows"/>
<property name="awt.toolkit" value="sun.awt.windows.WToolkit"/>
<property name="file.encoding.pkg" value="sun.io"/>
<property name="java.specification.version" value="1.8"/>
<property name="sun.cpu.isalist" value="amd64"/>
<property name="sun.jnu.encoding" value="Cp1252"/>
<property name="java.class.path" value="C:\Users\anell\Downloads\trabalho\Guess the number\target\test-classes;C:\Users\anell\Downloads\trabalho\Guess the number\target\classes;C:\Users\anell\.m2\repository\org\junit\jupiter\junit-jupiter\5.10.2\junit-jupiter-5.10.2.jar;C:\Users\anell\.m2\repository\org\junit\jupiter\junit-jupiter-api\5.10.2\junit-jupiter-api-5.10.2.jar;C:\Users\anell\.m2\repository\org\opentest4j\opentest4j\1.3.0\opentest4j-1.3.0.jar;C:\Users\anell\.m2\repository\org\junit\platform\junit-platform-commons\1.10.2\junit-platform-commons-1.10.2.jar;C:\Users\anell\.m2\repository\org\apiguardian\apiguardian-api\1.1.2\apiguardian-api-1.1.2.jar;C:\Users\anell\.m2\repository\org\junit\jupiter\junit-jupiter-params\5.10.2\junit-jupiter-params-5.10.2.jar;C:\Users\anell\.m2\repository\org\junit\jupiter\junit-jupiter-engine\5.10.2\junit-jupiter-engine-5.10.2.jar;C:\Users\anell\.m2\repository\org\junit\platform\junit-platform-engine\1.10.2\junit-platform-engine-1.10.2.jar;"/>
<property name="java.vm.vendor" value="Oracle Corporation"/>
<property name="sun.arch.data.model" value="64"/>
<property name="user.variant" value=""/>
<property name="java.vendor.url" value="http://java.oracle.com/"/>
<property name="user.timezone" value="America/Sao_Paulo"/>
<property name="java.vm.specification.version" value="1.8"/>
<property name="os.name" value="Windows 10"/>
<property name="user.country" value="BR"/>
<property name="sun.java.launcher" value="SUN_STANDARD"/>
<property name="sun.boot.library.path" value="C:\Program Files\Java\jdk1.8.0_202\jre\bin"/>
<property name="sun.java.command" value="C:\Users\anell\AppData\Local\Temp\surefire2485458507096907854\surefirebooter-20250501200944218_3.jar C:\Users\anell\AppData\Local\Temp\surefire2485458507096907854 2025-05-01T20-09-43_006-jvmRun1 surefire-20250501200944218_1tmp surefire_0-20250501200944218_2tmp"/>
<property name="surefire.test.class.path" value="C:\Users\anell\Downloads\trabalho\Guess the number\target\test-classes;C:\Users\anell\Downloads\trabalho\Guess the number\target\classes;C:\Users\anell\.m2\repository\org\junit\jupiter\junit-jupiter\5.10.2\junit-jupiter-5.10.2.jar;C:\Users\anell\.m2\repository\org\junit\jupiter\junit-jupiter-api\5.10.2\junit-jupiter-api-5.10.2.jar;C:\Users\anell\.m2\repository\org\opentest4j\opentest4j\1.3.0\opentest4j-1.3.0.jar;C:\Users\anell\.m2\repository\org\junit\platform\junit-platform-commons\1.10.2\junit-platform-commons-1.10.2.jar;C:\Users\anell\.m2\repository\org\apiguardian\apiguardian-api\1.1.2\apiguardian-api-1.1.2.jar;C:\Users\anell\.m2\repository\org\junit\jupiter\junit-jupiter-params\5.10.2\junit-jupiter-params-5.10.2.jar;C:\Users\anell\.m2\repository\org\junit\jupiter\junit-jupiter-engine\5.10.2\junit-jupiter-engine-5.10.2.jar;C:\Users\anell\.m2\repository\org\junit\platform\junit-platform-engine\1.10.2\junit-platform-engine-1.10.2.jar;"/>
<property name="sun.cpu.endian" value="little"/>
<property name="user.home" value="C:\Users\anell"/>
<property name="user.language" value="pt"/>
<property name="java.specification.vendor" value="Oracle Corporation"/>
<property name="java.home" value="C:\Program Files\Java\jdk1.8.0_202\jre"/>
<property name="basedir" value="C:\Users\anell\Downloads\trabalho\Guess the number"/>
<property name="file.separator" value="\"/>
<property name="line.separator" value="&#10;"/>
<property name="java.vm.specification.vendor" value="Oracle Corporation"/>
<property name="java.specification.name" value="Java Platform API Specification"/>
<property name="java.awt.graphicsenv" value="sun.awt.Win32GraphicsEnvironment"/>
<property name="surefire.real.class.path" value="C:\Users\anell\AppData\Local\Temp\surefire2485458507096907854\surefirebooter-20250501200944218_3.jar"/>
<property name="sun.boot.class.path" value="C:\Program Files\Java\jdk1.8.0_202\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\rt.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\sunrsasign.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_202\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_202\jre\classes"/>
<property name="user.script" value=""/>
<property name="sun.management.compiler" value="HotSpot 64-Bit Tiered Compilers"/>
<property name="java.runtime.version" value="1.8.0_202-b08"/>
<property name="user.name" value="anell"/>
<property name="path.separator" value=";"/>
<property name="os.version" value="10.0"/>
<property name="java.endorsed.dirs" value="C:\Program Files\Java\jdk1.8.0_202\jre\lib\endorsed"/>
<property name="java.runtime.name" value="Java(TM) SE Runtime Environment"/>
<property name="file.encoding" value="Cp1252"/>
<property name="java.vm.name" value="Java HotSpot(TM) 64-Bit Server VM"/>
<property name="localRepository" value="C:\Users\anell\.m2\repository"/>
<property name="java.vendor.url.bug" value="http://bugreport.sun.com/bugreport/"/>
<property name="java.io.tmpdir" value="C:\Users\anell\AppData\Local\Temp\"/>
<property name="java.version" value="1.8.0_202"/>
<property name="user.dir" value="C:\Users\anell\Downloads\trabalho\Guess the number"/>
<property name="os.arch" value="amd64"/>
<property name="java.vm.specification.name" value="Java Virtual Machine Specification"/>
<property name="java.awt.printerjob" value="sun.awt.windows.WPrinterJob"/>
<property name="sun.os.patch.level" value=""/>
<property name="java.library.path" value="C:\Program Files\Java\jdk1.8.0_202\jre\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\Program Files (x86)\Common Files\Oracle\Java\java8path;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\dotnet\;C:\Program Files\Git\cmd;C:\Program Files\nodejs\;C:\MinGW\bin;C:\Program Files\Apache\Maven\apache-maven-3.9.9\bin;C:\Program Files\Java\jdk1.8.0_202\bin;C:\Users\anell\AppData\Local\Programs\Python\Python313\Scripts\;C:\Users\anell\AppData\Local\Programs\Python\Python313\;C:\Users\anell\AppData\Local\Programs\Python\Launcher\;C:\Users\anell\AppData\Local\Microsoft\WindowsApps;C:\MinGW\bin\g++;C:\Users\anell\AppData\Local\Programs\Microsoft VS Code\bin\gcc;C:\Users\anell\AppData\Local\Programs\Microsoft VS Code\bin;C:\src\flutter\bin;C:\Users\anell\AppData\Roaming\npm;C:\Program Files\Apache\Maven\apache-maven-3.9.9\bin;;."/>
<property name="java.vm.info" value="mixed mode"/>
<property name="java.vendor" value="Oracle Corporation"/>
<property name="java.vm.version" value="25.202-b08"/>
<property name="java.ext.dirs" value="C:\Program Files\Java\jdk1.8.0_202\jre\lib\ext;C:\WINDOWS\Sun\Java\lib\ext"/>
<property name="sun.io.unicode.encoding" value="UnicodeLittle"/>
<property name="java.class.version" value="52.0"/>
</properties>
<testcase name="testTooHigh" classname="GameLogicTest" time="0.034"/>
<testcase name="testCorrectGuess" classname="GameLogicTest" time="0.0"/>
<testcase name="testTooLow" classname="GameLogicTest" time="0.003"/>
</testsuite>
Binary file not shown.
32 changes: 32 additions & 0 deletions Guess the number/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>br.com.exemplo</groupId>
<artifactId>meu-projeto</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.10.2</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.2.5</version>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package learningspace.swtest.examples;

public class GameLogic {
public String checkGuess(int guess, int correctNumber) {
if (guess == correctNumber) {
return "Correct!";
} else if (guess < correctNumber) {
return "Too low!";
} else {
return "Too high!";
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class GuessTheNumberGame extends Application {
private int targetNumber = (int) (Math.random() * 100) + 1;
private int numberOfTries = 0;

public static void main(String[] args) {
launch(args);
}

@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("Guess the Number Game");

Label titleLabel = new Label("Guess the Number (1-100)");
TextField guessInput = new TextField();
guessInput.setId("guessInput"); // ID adicionado
Label messageLabel = new Label();
messageLabel.setId("messageLabel"); // ID adicionado
VBox vbox = new VBox(titleLabel, guessInput, messageLabel);

guessInput.setOnAction(e -> {
try {
int userGuess = Integer.parseInt(guessInput.getText());
numberOfTries++;
if (userGuess < targetNumber) {
messageLabel.setText("Try higher.");
} else if (userGuess > targetNumber) {
messageLabel.setText("Try lower.");
} else {
messageLabel.setText("Congratulations! You guessed the number in " + numberOfTries + " tries.");
}
guessInput.clear();
} catch (NumberFormatException ex) {
messageLabel.setText("Invalid input. Enter a number.");
}
});

Scene scene = new Scene(vbox, 300, 150);
primaryStage.setScene(scene);
primaryStage.show();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import learningspace.swtest.examples.GameLogic;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;

public class GameLogicTest {

@Test
void testCorrectGuess() {
GameLogic logic = new GameLogic();
assertEquals("Correct!", logic.checkGuess(7, 7));
}

@Test
void testTooLow() {
GameLogic logic = new GameLogic();
assertEquals("Too low!", logic.checkGuess(5, 7));
}

@Test
void testTooHigh() {
GameLogic logic = new GameLogic();
assertEquals("Too high!", logic.checkGuess(9, 7));
}
}
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
GuessTheNumberGame.class
learningspace\swtest\examples\GameLogic.class
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
C:\Users\anell\Downloads\trabalho\Guess the number\src\main\java\learningspace\swtest\examples\GameLogic.java
C:\Users\anell\Downloads\trabalho\Guess the number\src\main\java\learningspace\swtest\examples\GuessTheNumberGame.java
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GameLogicTest.class
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
C:\Users\anell\Downloads\trabalho\Guess the number\src\test\java\learningspace\swtest\examples\GameLogicTest.java
4 changes: 4 additions & 0 deletions Guess the number/target/surefire-reports/GameLogicTest.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-------------------------------------------------------------------------------
Test set: GameLogicTest
-------------------------------------------------------------------------------
Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.082 s -- in GameLogicTest
Loading