Skip to content

Commit efbb5e4

Browse files
authored
Merge branch 'kishanrajput23:main' into main
2 parents d50c4c4 + 7a40c5b commit efbb5e4

File tree

28 files changed

+458
-15
lines changed

28 files changed

+458
-15
lines changed

.circleci/config.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# This config was automatically generated from your source code
2+
# Stacks detected: cicd:github-actions:.github/workflows,deps:java:.,deps:python:.,tool:gradle:
3+
version: 2.1
4+
orbs:
5+
python: circleci/python@2
6+
jobs:
7+
test-java:
8+
docker:
9+
- image: cimg/openjdk:17.0
10+
steps:
11+
- checkout
12+
- run:
13+
name: Calculate cache key
14+
command: |-
15+
find . -name 'pom.xml' -o -name 'gradlew*' -o -name '*.gradle*' | \
16+
sort | xargs cat > /tmp/CIRCLECI_CACHE_KEY
17+
- restore_cache:
18+
key: cache-{{ checksum "/tmp/CIRCLECI_CACHE_KEY" }}
19+
- run:
20+
command: ./gradlew check
21+
- store_test_results:
22+
path: build/test-results
23+
- save_cache:
24+
key: cache-{{ checksum "/tmp/CIRCLECI_CACHE_KEY" }}
25+
paths:
26+
- ~/.gradle/caches
27+
- store_artifacts:
28+
path: build/reports
29+
test-python:
30+
# Install dependencies and run tests
31+
docker:
32+
- image: cimg/python:3.8-node
33+
steps:
34+
- checkout
35+
- python/install-packages
36+
- run:
37+
name: Run tests
38+
command: pytest --junitxml=junit.xml || ((($? == 5)) && echo 'Did not find any tests to run.')
39+
- store_test_results:
40+
path: junit.xml
41+
deploy:
42+
# This is an example deploy job, not actually used by the workflow
43+
docker:
44+
- image: cimg/base:stable
45+
steps:
46+
# Replace this with steps to deploy to users
47+
- run:
48+
name: deploy
49+
command: '#e.g. ./deploy.sh'
50+
- run:
51+
name: found github actions config
52+
command: ':'
53+
workflows:
54+
build-and-test:
55+
jobs:
56+
- test-java
57+
- test-python
58+
# - deploy:
59+
# requires:
60+
# - test-java
61+
# - test-python

Guess The Number Game/pom.xml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<groupId>br.com.exemplo</groupId>
6+
<artifactId>meu-projeto</artifactId>
7+
<version>1.0-SNAPSHOT</version>
8+
9+
<properties>
10+
<maven.compiler.source>1.8</maven.compiler.source>
11+
<maven.compiler.target>1.8</maven.compiler.target>
12+
</properties>
13+
14+
<dependencies>
15+
<dependency>
16+
<groupId>org.junit.jupiter</groupId>
17+
<artifactId>junit-jupiter</artifactId>
18+
<version>5.10.2</version>
19+
<scope>test</scope>
20+
</dependency>
21+
</dependencies>
22+
23+
<build>
24+
<plugins>
25+
<plugin>
26+
<groupId>org.apache.maven.plugins</groupId>
27+
<artifactId>maven-surefire-plugin</artifactId>
28+
<version>3.2.5</version>
29+
</plugin>
30+
</plugins>
31+
</build>
32+
</project>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package learningspace.swtest.examples;
2+
3+
public class GameLogic {
4+
public String checkGuess(int guess, int correctNumber) {
5+
if (guess == correctNumber) {
6+
return "Correct!";
7+
} else if (guess < correctNumber) {
8+
return "Too low!";
9+
} else {
10+
return "Too high!";
11+
}
12+
}
13+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import javafx.application.Application;
2+
import javafx.scene.Scene;
3+
import javafx.scene.control.Label;
4+
import javafx.scene.control.TextField;
5+
import javafx.scene.layout.VBox;
6+
import javafx.stage.Stage;
7+
8+
public class GuessTheNumberGame extends Application {
9+
private int targetNumber = (int) (Math.random() * 100) + 1;
10+
private int numberOfTries = 0;
11+
12+
public static void main(String[] args) {
13+
launch(args);
14+
}
15+
16+
@Override
17+
public void start(Stage primaryStage) {
18+
primaryStage.setTitle("Guess the Number Game");
19+
20+
Label titleLabel = new Label("Guess the Number (1-100)");
21+
TextField guessInput = new TextField();
22+
guessInput.setId("guessInput"); // ID adicionado
23+
Label messageLabel = new Label();
24+
messageLabel.setId("messageLabel"); // ID adicionado
25+
VBox vbox = new VBox(titleLabel, guessInput, messageLabel);
26+
27+
guessInput.setOnAction(e -> {
28+
try {
29+
int userGuess = Integer.parseInt(guessInput.getText());
30+
numberOfTries++;
31+
if (userGuess < targetNumber) {
32+
messageLabel.setText("Try higher.");
33+
} else if (userGuess > targetNumber) {
34+
messageLabel.setText("Try lower.");
35+
} else {
36+
messageLabel.setText("Congratulations! You guessed the number in " + numberOfTries + " tries.");
37+
}
38+
guessInput.clear();
39+
} catch (NumberFormatException ex) {
40+
messageLabel.setText("Invalid input. Enter a number.");
41+
}
42+
});
43+
44+
Scene scene = new Scene(vbox, 300, 150);
45+
primaryStage.setScene(scene);
46+
primaryStage.show();
47+
}
48+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import learningspace.swtest.examples.GameLogic;
2+
import org.junit.jupiter.api.Test;
3+
import static org.junit.jupiter.api.Assertions.*;
4+
5+
public class GameLogicTest {
6+
7+
@Test
8+
void testCorrectGuess() {
9+
GameLogic logic = new GameLogic();
10+
assertEquals("Correct!", logic.checkGuess(7, 7));
11+
}
12+
13+
@Test
14+
void testTooLow() {
15+
GameLogic logic = new GameLogic();
16+
assertEquals("Too low!", logic.checkGuess(5, 7));
17+
}
18+
19+
@Test
20+
void testTooHigh() {
21+
GameLogic logic = new GameLogic();
22+
assertEquals("Too high!", logic.checkGuess(9, 7));
23+
}
24+
}
Binary file not shown.
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
GuessTheNumberGame.class
2+
learningspace\swtest\examples\GameLogic.class
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
C:\Users\anell\Downloads\trabalho\Guess the number\src\main\java\learningspace\swtest\examples\GameLogic.java
2+
C:\Users\anell\Downloads\trabalho\Guess the number\src\main\java\learningspace\swtest\examples\GuessTheNumberGame.java
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
GameLogicTest.class

0 commit comments

Comments
 (0)