changed the file structure
This commit is contained in:
parent
cd81159162
commit
b1c3582880
391 changed files with 675 additions and 0 deletions
7
Code/Steiner/guessing_game/game01/.vscode/settings.json
vendored
Normal file
7
Code/Steiner/guessing_game/game01/.vscode/settings.json
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"java.project.sourcePaths": ["src"],
|
||||
"java.project.outputPath": "bin",
|
||||
"java.project.referencedLibraries": [
|
||||
"lib/**/*.jar"
|
||||
]
|
||||
}
|
18
Code/Steiner/guessing_game/game01/README.md
Normal file
18
Code/Steiner/guessing_game/game01/README.md
Normal file
|
@ -0,0 +1,18 @@
|
|||
## Getting Started
|
||||
|
||||
Welcome to the VS Code Java world. Here is a guideline to help you get started to write Java code in Visual Studio Code.
|
||||
|
||||
## Folder Structure
|
||||
|
||||
The workspace contains two folders by default, where:
|
||||
|
||||
- `src`: the folder to maintain sources
|
||||
- `lib`: the folder to maintain dependencies
|
||||
|
||||
Meanwhile, the compiled output files will be generated in the `bin` folder by default.
|
||||
|
||||
> If you want to customize the folder structure, open `.vscode/settings.json` and update the related settings there.
|
||||
|
||||
## Dependency Management
|
||||
|
||||
The `JAVA PROJECTS` view allows you to manage your dependencies. More details can be found [here](https://github.com/microsoft/vscode-java-dependency#manage-dependencies).
|
BIN
Code/Steiner/guessing_game/game01/bin/App.class
Normal file
BIN
Code/Steiner/guessing_game/game01/bin/App.class
Normal file
Binary file not shown.
42
Code/Steiner/guessing_game/game01/src/App.java
Normal file
42
Code/Steiner/guessing_game/game01/src/App.java
Normal file
|
@ -0,0 +1,42 @@
|
|||
import java.util.Random;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class App {
|
||||
static Scanner scan = new Scanner(System.in);
|
||||
static Random random = new Random();
|
||||
|
||||
public static void main(String[] args) {
|
||||
int numberOfTries = 0;
|
||||
int maxNumber = 100;
|
||||
int randomNumber = random.nextInt(maxNumber) + 1;
|
||||
int userinput = 0;
|
||||
|
||||
System.out.println("Number for the dev to check if the games is working: " + randomNumber);
|
||||
|
||||
System.out.println("Welcome to the Number Guessing Game!");
|
||||
System.out.println("I have selected a random number between " + 0 + " and " + maxNumber + ".");
|
||||
System.out.println("Try to guess the number.");
|
||||
|
||||
while (true) {
|
||||
numberOfTries++;
|
||||
System.out.println(numberOfTries + ". Try");
|
||||
userinput = scan.nextInt();
|
||||
|
||||
if (randomNumber > userinput) {
|
||||
System.out.println("Lmao no the number is bigger");
|
||||
} else if (randomNumber == userinput) {
|
||||
System.out.println("You got the right number my brother");
|
||||
System.out.println("You only needed " + numberOfTries + " tries");
|
||||
break;
|
||||
} else {
|
||||
System.out.println("No the number is smaller");
|
||||
}
|
||||
}
|
||||
|
||||
if (numberOfTries == 1) {
|
||||
System.out.println("No offense but are you sure you didn't cheat?");
|
||||
}
|
||||
scan.close();
|
||||
}
|
||||
|
||||
}
|
7
Code/Steiner/guessing_game/game1/.vscode/settings.json
vendored
Normal file
7
Code/Steiner/guessing_game/game1/.vscode/settings.json
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"java.project.sourcePaths": ["src"],
|
||||
"java.project.outputPath": "bin",
|
||||
"java.project.referencedLibraries": [
|
||||
"lib/**/*.jar"
|
||||
]
|
||||
}
|
18
Code/Steiner/guessing_game/game1/README.md
Normal file
18
Code/Steiner/guessing_game/game1/README.md
Normal file
|
@ -0,0 +1,18 @@
|
|||
## Getting Started
|
||||
|
||||
Welcome to the VS Code Java world. Here is a guideline to help you get started to write Java code in Visual Studio Code.
|
||||
|
||||
## Folder Structure
|
||||
|
||||
The workspace contains two folders by default, where:
|
||||
|
||||
- `src`: the folder to maintain sources
|
||||
- `lib`: the folder to maintain dependencies
|
||||
|
||||
Meanwhile, the compiled output files will be generated in the `bin` folder by default.
|
||||
|
||||
> If you want to customize the folder structure, open `.vscode/settings.json` and update the related settings there.
|
||||
|
||||
## Dependency Management
|
||||
|
||||
The `JAVA PROJECTS` view allows you to manage your dependencies. More details can be found [here](https://github.com/microsoft/vscode-java-dependency#manage-dependencies).
|
BIN
Code/Steiner/guessing_game/game1/bin/App.class
Normal file
BIN
Code/Steiner/guessing_game/game1/bin/App.class
Normal file
Binary file not shown.
43
Code/Steiner/guessing_game/game1/src/App.java
Normal file
43
Code/Steiner/guessing_game/game1/src/App.java
Normal file
|
@ -0,0 +1,43 @@
|
|||
import java.util.Random;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class App {
|
||||
public static void main(String[] args) {
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
Random random = new Random();
|
||||
|
||||
int minRange = -1000;
|
||||
int maxRange = 1000;
|
||||
|
||||
int randomNumber = random.nextInt(maxRange - minRange + 1) + minRange;
|
||||
int numberOfTries = 0;
|
||||
int inputNumber;
|
||||
|
||||
// System.out.println("Number for the dev to check if the games is working: " +
|
||||
// randomNumber);
|
||||
|
||||
System.out.println("Welcome to the Number Guessing Game!");
|
||||
System.out.println("I have selected a random number between " + minRange + " and " + maxRange + ".");
|
||||
System.out.println("Try to guess the number.");
|
||||
|
||||
do {
|
||||
System.out.print("Enter your guess: ");
|
||||
inputNumber = scanner.nextInt();
|
||||
numberOfTries++;
|
||||
|
||||
if (inputNumber < randomNumber) {
|
||||
System.out.println("The number is higher. Try again. (" + numberOfTries + " Try)");
|
||||
} else if (inputNumber > randomNumber) {
|
||||
System.out.println("The number is lower. Try again. (" + numberOfTries + " Try)");
|
||||
} else {
|
||||
System.out.println(
|
||||
"Congratulations! You guessed the number " + randomNumber + " in " + numberOfTries + " tries.");
|
||||
}
|
||||
} while (inputNumber != randomNumber);
|
||||
if (numberOfTries == 1) {
|
||||
System.out.println("No offense but are you sure you didn't cheat?");
|
||||
}
|
||||
|
||||
scanner.close();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue