Fixed the repository
This commit is contained in:
parent
d3092e64bf
commit
b2cded4072
318 changed files with 8017 additions and 144 deletions
|
@ -3,6 +3,5 @@
|
|||
"java.project.outputPath": "bin",
|
||||
"java.project.referencedLibraries": [
|
||||
"lib/**/*.jar"
|
||||
],
|
||||
"java.format.settings.url": "eclipse-formatter.xml"
|
||||
]
|
||||
}
|
BIN
Code/16.01.24 PrüfungJava/bin/App.class
Normal file
BIN
Code/16.01.24 PrüfungJava/bin/App.class
Normal file
Binary file not shown.
62
Code/16.01.24 PrüfungJava/src/App.java
Normal file
62
Code/16.01.24 PrüfungJava/src/App.java
Normal file
|
@ -0,0 +1,62 @@
|
|||
// Luca Fabian Burger
|
||||
// Aufgabe 3
|
||||
|
||||
public class App {
|
||||
public static void main(String[] args) throws Exception {
|
||||
int[] sitzPlaetze = new int[100];
|
||||
sitzPlaetze[1] = 45;
|
||||
sitzPlaetze[17] = 12;
|
||||
sitzPlaetze[32] = 25;
|
||||
sitzPlaetze[45] = 54;
|
||||
sitzPlaetze[85] = 88;
|
||||
|
||||
double durchscnittalter = getAvarageAge(sitzPlaetze);
|
||||
int[] belegteSitze = getBelegteSitze(sitzPlaetze);
|
||||
int youngestAge = getYoungestAge(sitzPlaetze, belegteSitze);
|
||||
printOut("Das durchscnittliche Alter ist : ", durchscnittalter);
|
||||
printOut("Das jüngste Alter ist : ", youngestAge);
|
||||
|
||||
}
|
||||
|
||||
public static int[] getBelegteSitze(int[] sitzPlaetze) {
|
||||
int controllNumber = 0;
|
||||
int[] belegteSitze = new int[sitzPlaetze.length];
|
||||
for (int i = 0; i < sitzPlaetze.length; i++) {
|
||||
if (sitzPlaetze[i] > 0) {
|
||||
belegteSitze[controllNumber] = i;
|
||||
controllNumber++;
|
||||
}
|
||||
}
|
||||
return belegteSitze;
|
||||
}
|
||||
|
||||
public static double getAvarageAge(int[] sitzPlaetze) {
|
||||
double avarageAge = 0;
|
||||
int anzahlBesucher = 0;
|
||||
|
||||
for (int i = 0; i < sitzPlaetze.length; i++) {
|
||||
if (sitzPlaetze[i] > 0) {
|
||||
avarageAge += sitzPlaetze[i];
|
||||
anzahlBesucher++;
|
||||
}
|
||||
}
|
||||
return avarageAge / anzahlBesucher;
|
||||
}
|
||||
|
||||
public static int getYoungestAge(int[] sitzPlaetze, int[] belegteSitze) {
|
||||
int youngestAge = 100000;
|
||||
for (int i = 0; i < belegteSitze.length; i++) {
|
||||
for (int o = 0; o < belegteSitze.length; o++) {
|
||||
if (sitzPlaetze[i] < youngestAge && sitzPlaetze[i] != 0) {
|
||||
youngestAge = sitzPlaetze[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
return youngestAge;
|
||||
|
||||
}
|
||||
|
||||
public static void printOut(String myText, double myValue) {
|
||||
System.out.println(myText + myValue);
|
||||
}
|
||||
}
|
7
Code/2dArrays/.vscode/settings.json
vendored
Normal file
7
Code/2dArrays/.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/2dArrays/README.md
Normal file
18
Code/2dArrays/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/2dArrays/bin/App.class
Normal file
BIN
Code/2dArrays/bin/App.class
Normal file
Binary file not shown.
BIN
Code/2dArrays/src/App.class
Normal file
BIN
Code/2dArrays/src/App.class
Normal file
Binary file not shown.
35
Code/2dArrays/src/App.java
Normal file
35
Code/2dArrays/src/App.java
Normal file
|
@ -0,0 +1,35 @@
|
|||
public class App {
|
||||
|
||||
public static void main(String[] args) {
|
||||
int[][] matrix1 = {
|
||||
// x 0 1 2
|
||||
{ 1, 2, 3 }, // 0
|
||||
{ 4, 5, 6 }, // 1
|
||||
{ 7, 8, 9 } // 2 y
|
||||
};
|
||||
|
||||
int[][] matrix2 = {
|
||||
{ 9, 8, 7 },
|
||||
{ 6, 5, 4 },
|
||||
{ 3, 2, 1 }
|
||||
};
|
||||
|
||||
System.out.println(matrix1[1][2]);
|
||||
System.out.println(matrix2[1][2]);
|
||||
|
||||
int[][] sumMatrix = new int[matrix1.length][matrix1.length];
|
||||
|
||||
for (int i = 0; i < matrix1.length; i++) {
|
||||
for (int j = 0; j < matrix1[i].length; j++) {
|
||||
sumMatrix[j][i] = matrix1[j][i] + matrix2[j][i];
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < matrix1.length; i++) {
|
||||
for (int j = 0; j < matrix1[i].length; j++) {
|
||||
System.out.print(sumMatrix[i][j] + " ");
|
||||
}
|
||||
System.out.println("");
|
||||
}
|
||||
}
|
||||
}
|
7
Code/30.8.23/.vscode/settings.json
vendored
Normal file
7
Code/30.8.23/.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/30.8.23/README.md
Normal file
18
Code/30.8.23/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/30.8.23/bin/App.class
Normal file
BIN
Code/30.8.23/bin/App.class
Normal file
Binary file not shown.
17
Code/30.8.23/src/App.java
Normal file
17
Code/30.8.23/src/App.java
Normal file
|
@ -0,0 +1,17 @@
|
|||
import java.util.Scanner;
|
||||
|
||||
public class App {
|
||||
static Scanner scan = new Scanner(System.in);
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
int myNumber = 12;
|
||||
System.out.println("Please type a number to add:");
|
||||
int numberToAdd = scan.nextInt();
|
||||
|
||||
myNumber += numberToAdd;
|
||||
|
||||
System.out.println(myNumber);
|
||||
|
||||
scan.close();
|
||||
}
|
||||
}
|
7
Code/5.12.23-JavaExam3/.vscode/settings.json
vendored
Normal file
7
Code/5.12.23-JavaExam3/.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/5.12.23-JavaExam3/README.md
Normal file
18
Code/5.12.23-JavaExam3/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/5.12.23-JavaExam3/bin/App.class
Normal file
BIN
Code/5.12.23-JavaExam3/bin/App.class
Normal file
Binary file not shown.
37
Code/5.12.23-JavaExam3/src/App.java
Normal file
37
Code/5.12.23-JavaExam3/src/App.java
Normal file
|
@ -0,0 +1,37 @@
|
|||
// Luca Fabian Burger
|
||||
// Aufgabe 11
|
||||
|
||||
public class App {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
// Dreiecks-Berechnungen nach Pythagoras
|
||||
// hypo meint Hypothenuse
|
||||
|
||||
// Dreieck 1
|
||||
double seiteA1 = 3;
|
||||
double seiteB1 = 4;
|
||||
double hypo1 = getHypo(seiteA1, seiteB1);
|
||||
printHypo(hypo1, "Erstes Dreieck");
|
||||
|
||||
// Dreieck 2
|
||||
double seiteA2 = 4;
|
||||
double seiteB2 = 5;
|
||||
double hypo2 = getHypo(seiteA2, seiteB2);
|
||||
printHypo(hypo2, "Zweites Dreieck");
|
||||
|
||||
// Dreieck 3
|
||||
double seiteA3 = 5;
|
||||
double seiteB3 = 6;
|
||||
double hypo3 = getHypo(seiteA3, seiteB3);
|
||||
printHypo(hypo3, "Drittes Dreieck");
|
||||
}
|
||||
|
||||
public static double getHypo(double seiteA, double seiteB) {
|
||||
return Math.sqrt(seiteA * seiteA + seiteB * seiteB);
|
||||
}
|
||||
|
||||
public static void printHypo(double hypo, String myText) {
|
||||
System.out.println(myText + ": " + hypo);
|
||||
}
|
||||
}
|
7
Code/Boolean/.vscode/settings.json
vendored
Normal file
7
Code/Boolean/.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/Boolean/README.md
Normal file
18
Code/Boolean/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/Boolean/bin/App.class
Normal file
BIN
Code/Boolean/bin/App.class
Normal file
Binary file not shown.
15
Code/Boolean/src/App.java
Normal file
15
Code/Boolean/src/App.java
Normal file
|
@ -0,0 +1,15 @@
|
|||
public class App {
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
boolean a = 1 == 1;
|
||||
boolean b = 1 != 2;
|
||||
boolean c = a == b;
|
||||
boolean d = c != b;
|
||||
|
||||
if (d) {
|
||||
System.out.println("d is true see: " + d);
|
||||
} else {
|
||||
System.out.println("d is false see: " + d);
|
||||
}
|
||||
}
|
||||
}
|
7
Code/Debuging_Prüfungen/debuging/.vscode/settings.json
vendored
Normal file
7
Code/Debuging_Prüfungen/debuging/.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/Debuging_Prüfungen/debuging/README.md
Normal file
18
Code/Debuging_Prüfungen/debuging/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/Debuging_Prüfungen/debuging/bin/App.class
Normal file
BIN
Code/Debuging_Prüfungen/debuging/bin/App.class
Normal file
Binary file not shown.
27
Code/Debuging_Prüfungen/debuging/src/App.java
Normal file
27
Code/Debuging_Prüfungen/debuging/src/App.java
Normal file
|
@ -0,0 +1,27 @@
|
|||
// Luca Fabian Burger
|
||||
// Aufgabe 13
|
||||
// Die Eingabe von Fliesskomazahlen funktioniert nicht
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
public class App {
|
||||
static Scanner scan = new Scanner(System.in);
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
System.out.println("Was ist dein Vorname?");
|
||||
String vorname = scan.next();
|
||||
|
||||
System.out.println("Wie schwer sind Sie in KG? (mit Kommastellen)");
|
||||
double gewicht = scan.nextDouble();
|
||||
|
||||
System.out.println("Wie gross sind Sie in Meter (mit Kommastellen)");
|
||||
double groesse = scan.nextDouble();
|
||||
|
||||
double bmi = gewicht / (groesse * groesse);
|
||||
|
||||
System.out.println("Lieber " + vorname + " dein BMI beträgt: " + bmi);
|
||||
|
||||
scan.close();
|
||||
}
|
||||
}
|
7
Code/Exchange/.vscode/settings.json
vendored
Normal file
7
Code/Exchange/.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/Exchange/README.md
Normal file
18
Code/Exchange/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/Exchange/bin/App.class
Normal file
BIN
Code/Exchange/bin/App.class
Normal file
Binary file not shown.
|
@ -1,22 +1,24 @@
|
|||
package Archiv;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class exchange {
|
||||
public static void main(String[] args) {
|
||||
public class App {
|
||||
static Scanner scan = new Scanner(System.in);
|
||||
|
||||
int x = 5;
|
||||
int y = 7;
|
||||
public static void main(String[] args) throws Exception {
|
||||
System.out.println("Define the variable x, if you would be so kind:");
|
||||
int x = scan.nextInt();
|
||||
System.out.println("now again for y, please:");
|
||||
int y = scan.nextInt();
|
||||
|
||||
// Vor dem Tausch
|
||||
System.out.println("Before the exchange");
|
||||
System.out.println(x);
|
||||
System.out.println(y);
|
||||
|
||||
// Tausch
|
||||
int z = 0;
|
||||
z = x;
|
||||
// Exchange
|
||||
int z = x;
|
||||
x = y;
|
||||
y = z;
|
||||
|
||||
// Nach dem Tausch
|
||||
System.out.println("after the exchange");
|
||||
System.out.println(x);
|
||||
System.out.println(y);
|
||||
|
||||
|
@ -29,5 +31,7 @@ public class exchange {
|
|||
* Sie dürfen nur Code zwischen den beiden Kommentaren //Tausch
|
||||
* und //Nach dem Tausch hinzufügen!
|
||||
*/
|
||||
|
||||
scan.close();
|
||||
}
|
||||
}
|
7
Code/Geografie/.vscode/settings.json
vendored
Normal file
7
Code/Geografie/.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/Geografie/README.md
Normal file
18
Code/Geografie/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/Geografie/bin/App.class
Normal file
BIN
Code/Geografie/bin/App.class
Normal file
Binary file not shown.
95
Code/Geografie/src/App.java
Normal file
95
Code/Geografie/src/App.java
Normal file
|
@ -0,0 +1,95 @@
|
|||
import java.util.Scanner;
|
||||
|
||||
public class App {
|
||||
static Scanner scan = new Scanner(System.in);
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
// variables for score
|
||||
double question = 0;
|
||||
final double QuestionTotal = 6;
|
||||
double grade = 1;
|
||||
|
||||
// Anwsers
|
||||
System.out.println("is Sargans in Graubünden? y/n");
|
||||
String anwserOne = scan.nextLine();
|
||||
System.out.println("Is Lichtenstein bigger than St. Gallen? y/n");
|
||||
String anwserTwo = scan.nextLine();
|
||||
System.out.println("is Bielefeld real? y/n");
|
||||
String anwserThree = scan.nextLine();
|
||||
System.out.println("Is St. Moritz in Switzerland y/n");
|
||||
String anwserFor = scan.nextLine();
|
||||
System.out.println("Has Lichtenstein a own army y/n");
|
||||
String anwserFive = scan.nextLine();
|
||||
System.out.println("Is the Matterhorn a mountain y/n");
|
||||
String anwserSix = scan.nextLine();
|
||||
|
||||
// correction
|
||||
if (anwserOne.equalsIgnoreCase("n")) {
|
||||
question++;
|
||||
}
|
||||
if (anwserTwo.equalsIgnoreCase("n")) {
|
||||
question++;
|
||||
}
|
||||
if (anwserThree.equalsIgnoreCase("n")) {
|
||||
question++;
|
||||
}
|
||||
if (anwserFor.equalsIgnoreCase("y")) {
|
||||
question++;
|
||||
}
|
||||
if (anwserFive.equalsIgnoreCase("n")) {
|
||||
question++;
|
||||
}
|
||||
if (anwserSix.equalsIgnoreCase("y")) {
|
||||
question++;
|
||||
}
|
||||
|
||||
// Score
|
||||
grade = question / QuestionTotal * 5 + 1;
|
||||
|
||||
/*
|
||||
* // Rounding
|
||||
* if (grade >= 1 && grade < 1.5) {
|
||||
* grade = 1;
|
||||
* } else if (grade >= 1.5 && grade < 2.5) {
|
||||
* grade = 2;
|
||||
* } else if (grade >= 2.5 && grade < 3.5) {
|
||||
* grade = 3;
|
||||
* } else if (grade >= 3.5 && grade < 4.5) {
|
||||
* grade = 4;
|
||||
* } else if (grade >= 4.5 && grade < 5) {
|
||||
* grade = 5;
|
||||
* }
|
||||
*/
|
||||
|
||||
// text feedback
|
||||
switch ((int) grade) {
|
||||
case 1:
|
||||
System.out.println("Ouh tuff buddy");
|
||||
break;
|
||||
case 2:
|
||||
System.out.println("Please learn more");
|
||||
break;
|
||||
case 3:
|
||||
System.out.println("So close buddy");
|
||||
break;
|
||||
case 4:
|
||||
System.out.println("Good job Buddy");
|
||||
break;
|
||||
case 5:
|
||||
double distantToPerfection = (double) 6 - grade;
|
||||
System.out.println("Absolut Mastermind only " + distantToPerfection + " short to perfection");
|
||||
break;
|
||||
case 6:
|
||||
System.out.println("Mastermind");
|
||||
break;
|
||||
default:
|
||||
System.out.println("Error");
|
||||
break;
|
||||
}
|
||||
|
||||
System.out.println("In other words your grade is: " + grade);
|
||||
scan.close();
|
||||
|
||||
}
|
||||
}
|
1
Code/IMS-java
Submodule
1
Code/IMS-java
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit d3092e64bf931d5b98fa000fca03fa1069647646
|
7
Code/MATHE/.vscode/settings.json
vendored
Normal file
7
Code/MATHE/.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/MATHE/README.md
Normal file
18
Code/MATHE/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/MATHE/bin/App.class
Normal file
BIN
Code/MATHE/bin/App.class
Normal file
Binary file not shown.
37
Code/MATHE/src/App.java
Normal file
37
Code/MATHE/src/App.java
Normal file
|
@ -0,0 +1,37 @@
|
|||
// Alle Brechnungen mit der Annahme Juni und schönes Wetter
|
||||
public class App {
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
// Grösse der Fahrzeuge
|
||||
double pkw = 2.2;
|
||||
// Lastwagen und Büsse
|
||||
double lastwagen = 10;
|
||||
double mottorad = 1.8;
|
||||
|
||||
// Wahrscheinschlichkeit
|
||||
double waPkw = 70;
|
||||
double waLastwagen = 15;
|
||||
double waMottorad = 15;
|
||||
|
||||
// Strecke
|
||||
double laenge = 6000;
|
||||
double spuren = 2;
|
||||
|
||||
// brechnungen
|
||||
|
||||
// Strecke
|
||||
double strecke = laenge * spuren;
|
||||
|
||||
// durchscnittliche länge
|
||||
// plus 6 2m abstand für 3 fahrzeuge
|
||||
double anzahl = (pkw * waPkw + lastwagen * waLastwagen + mottorad * waMottorad + 6) / 100;
|
||||
|
||||
// durschnittliche länge
|
||||
System.err.println(anzahl);
|
||||
|
||||
// verrechnung
|
||||
int fahrzeuge = (int) (strecke / anzahl);
|
||||
System.out.println("Die durchsnittliche anzahl Fahrzeuge für eine Staustrecke von " + laenge + "beträgt: "
|
||||
+ fahrzeuge);
|
||||
}
|
||||
}
|
7
Code/Uhrzeiten/Time/.vscode/settings.json
vendored
Normal file
7
Code/Uhrzeiten/Time/.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/Uhrzeiten/Time/README.md
Normal file
18
Code/Uhrzeiten/Time/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/Uhrzeiten/Time/bin/App.class
Normal file
BIN
Code/Uhrzeiten/Time/bin/App.class
Normal file
Binary file not shown.
39
Code/Uhrzeiten/Time/src/App.java
Normal file
39
Code/Uhrzeiten/Time/src/App.java
Normal file
|
@ -0,0 +1,39 @@
|
|||
|
||||
/*
|
||||
* Bis 8:00 Morgen --> morning
|
||||
* Bis 12:00 Vormittag --> late noon
|
||||
* bis 15:59 Nachmittag --> afternoon
|
||||
* 16:00 Zvieri --> "Zvieri"
|
||||
* bis 21:00 Abend --> Evening
|
||||
* bis 00:00 Nacht --> Night
|
||||
*/
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
public class App {
|
||||
static Scanner scan = new Scanner(System.in);
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
System.out.println(
|
||||
"What time is it (you can use any DECIMAL number but use \",\" for decimal numbers please my terminal is acting funky idk why frfr)");
|
||||
double localTime = scan.nextDouble();
|
||||
|
||||
if (localTime < (double) 0) {
|
||||
System.out.println("I don't think that's true");
|
||||
} else if (localTime > (double) 24) {
|
||||
System.out.println("Where do you live, my guy?");
|
||||
} else if (localTime == (double) 16) {
|
||||
System.out.println("It's Zvieri");
|
||||
} else if (localTime <= (double) 8) {
|
||||
System.out.println("It's morning");
|
||||
} else if (localTime <= (double) 12) {
|
||||
System.out.println("It's late morning");
|
||||
} else if (localTime <= (double) 15) {
|
||||
System.out.println("It's noon");
|
||||
} else if (localTime <= (double) 21) {
|
||||
System.out.println("It's evening");
|
||||
} else {
|
||||
System.out.println("It's night");
|
||||
}
|
||||
}
|
||||
}
|
7
Code/Variablen_Deklarieren/variablen-deklarieren/.vscode/settings.json
vendored
Normal file
7
Code/Variablen_Deklarieren/variablen-deklarieren/.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/Variablen_Deklarieren/variablen-deklarieren/README.md
Normal file
18
Code/Variablen_Deklarieren/variablen-deklarieren/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/Variablen_Deklarieren/variablen-deklarieren/bin/App.class
Normal file
BIN
Code/Variablen_Deklarieren/variablen-deklarieren/bin/App.class
Normal file
Binary file not shown.
|
@ -0,0 +1,44 @@
|
|||
public class App {
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
// Variables
|
||||
byte byteLuca;
|
||||
short shortLuca;
|
||||
int intLuca;
|
||||
long longLuca;
|
||||
float floatLuca;
|
||||
double doubleLuca;
|
||||
|
||||
// Strings to shorten the text
|
||||
String a = "\"byteLuca\"";
|
||||
String b = "\"shortLuca\"";
|
||||
String c = "\"intLuca\"";
|
||||
String d = "\"longLuca\"";
|
||||
String e = "\"floatLuca\"";
|
||||
String f = "\"doubleLuca\"";
|
||||
String g = "This is the worth of variable ";
|
||||
String h = " from the category ";
|
||||
|
||||
// Worth
|
||||
byteLuca = 127;
|
||||
shortLuca = 128;
|
||||
intLuca = 999;
|
||||
longLuca = 878897;
|
||||
floatLuca = 3.54325f;
|
||||
doubleLuca = 3.35355353;
|
||||
|
||||
// Text block + "Datetype" + category: worth
|
||||
System.out.println(g + a + h + "byte: " + byteLuca);
|
||||
System.out.println(g + b + h + "short: " + shortLuca);
|
||||
System.out.println(g + c + h + "int: " + intLuca);
|
||||
System.out.println(g + d + h + "long: " + longLuca);
|
||||
System.out.println(g + e + h + "float: " + floatLuca);
|
||||
System.out.println(g + f + h + "double: " + doubleLuca);
|
||||
|
||||
/*
|
||||
*
|
||||
* This comment just demonstrates that i can comment throw multible lines
|
||||
* There's no other use for this, please ignore, thank you
|
||||
*/
|
||||
}
|
||||
}
|
7
Code/Variablen_sortieren/.vscode/settings.json
vendored
Normal file
7
Code/Variablen_sortieren/.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/Variablen_sortieren/README.md
Normal file
18
Code/Variablen_sortieren/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/Variablen_sortieren/bin/Input.class
Normal file
BIN
Code/Variablen_sortieren/bin/Input.class
Normal file
Binary file not shown.
Binary file not shown.
46
Code/Variablen_sortieren/src/Input.java
Normal file
46
Code/Variablen_sortieren/src/Input.java
Normal file
|
@ -0,0 +1,46 @@
|
|||
import java.util.Scanner;
|
||||
|
||||
public class Input {
|
||||
static Scanner scan = new Scanner(System.in);
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
System.out.println("Zahl 1:");
|
||||
int numberOne = scan.nextInt();
|
||||
|
||||
System.out.println("Zahl 2:");
|
||||
int numberTwo = scan.nextInt();
|
||||
|
||||
System.out.println("Zahl 3:");
|
||||
int numberThree = scan.nextInt();
|
||||
|
||||
System.out.println("a equals: " + numberOne);
|
||||
System.out.println("b equals: " + numberTwo);
|
||||
System.out.println("c equals: " + numberThree);
|
||||
|
||||
/*
|
||||
* Deaktiviert da ich das logische Und noch nicht kennen darf
|
||||
*
|
||||
* if (numberOne > numberTwo && numberOne > numberThree) {
|
||||
* System.out.println("The largest variable is: a");
|
||||
* } else if (numberTwo > numberOne && numberTwo > numberThree) {
|
||||
* System.out.println("The largest variable is: b");
|
||||
* } else if (numberThree > numberOne && numberThree > numberTwo) {
|
||||
* System.out.println("The largest variable is: c");
|
||||
* } else
|
||||
* System.out.println("All variables have the same value");
|
||||
*/
|
||||
|
||||
if (numberOne > numberTwo) {
|
||||
if (numberOne > numberThree) {
|
||||
System.out.println(numberOne + " (aka a) is the biggest");
|
||||
}
|
||||
} else if (numberTwo > numberThree) {
|
||||
System.out.println(numberTwo + " (aka b) is the biggest");
|
||||
} else if (numberThree != numberOne) {
|
||||
System.out.println(numberThree + " (aka c) is the biggest");
|
||||
} else {
|
||||
System.out.println("all variables are the same thing");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,8 +1,6 @@
|
|||
package Archiv;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class Sort {
|
||||
public class Zufall {
|
||||
public static void main(String[] args) throws Exception {
|
||||
// Creating a Random object
|
||||
Random random = new Random();
|
||||
|
@ -28,6 +26,5 @@ public class Sort {
|
|||
System.out.println("The largest variable is: c");
|
||||
} else
|
||||
System.out.println("All variables have the same value");
|
||||
|
||||
}
|
||||
}
|
7
Code/arraysPractice/.vscode/settings.json
vendored
Normal file
7
Code/arraysPractice/.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/arraysPractice/README.md
Normal file
18
Code/arraysPractice/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/arraysPractice/bin/App.class
Normal file
BIN
Code/arraysPractice/bin/App.class
Normal file
Binary file not shown.
25
Code/arraysPractice/src/App.java
Normal file
25
Code/arraysPractice/src/App.java
Normal file
|
@ -0,0 +1,25 @@
|
|||
public class App {
|
||||
public static void main(String[] args) throws Exception {
|
||||
double[] arr = new double[1000];
|
||||
|
||||
for (int i = 0; i < arr.length; i++) {
|
||||
arr[i] = 0.1;
|
||||
}
|
||||
|
||||
String student[] = { "Gianna", "Niki", "Luca", "Yasin", "Andi", "Beis", "Stipe", "Patrick", "Andrin", "Yasin" };
|
||||
System.out.println("The class has: " + student.length + " students");
|
||||
|
||||
for (int i = 0; i < arr.length; i++) {
|
||||
arr[i] = arr[i] + 4.12;
|
||||
arr[i] = arr[i] + i;
|
||||
}
|
||||
|
||||
for (int i = 0; i < arr.length; i++) {
|
||||
System.out.println(arr[i]);
|
||||
}
|
||||
|
||||
for (int i = 0; i < student.length; i++) {
|
||||
System.out.println("Student with the index " + i + " is called: " + student[i]);
|
||||
}
|
||||
}
|
||||
}
|
7
Code/arraysTest/.vscode/settings.json
vendored
Normal file
7
Code/arraysTest/.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/arraysTest/README.md
Normal file
18
Code/arraysTest/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/arraysTest/bin/App.class
Normal file
BIN
Code/arraysTest/bin/App.class
Normal file
Binary file not shown.
14
Code/arraysTest/src/App.java
Normal file
14
Code/arraysTest/src/App.java
Normal file
|
@ -0,0 +1,14 @@
|
|||
public class App {
|
||||
public static void main(String[] args) throws Exception {
|
||||
int[] numbersForMath = new int[3];
|
||||
numbersForMath[0] = 24;
|
||||
numbersForMath[1] = 56;
|
||||
int sum = calcSum(numbersForMath[0], numbersForMath[1]);
|
||||
System.out.println(sum);
|
||||
System.out.println(numbersForMath[2]);
|
||||
}
|
||||
|
||||
public static int calcSum(int numberOne, int numberTwo) {
|
||||
return numberOne + numberTwo;
|
||||
}
|
||||
}
|
7
Code/aufgabeZwei/.vscode/settings.json
vendored
Normal file
7
Code/aufgabeZwei/.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/aufgabeZwei/README.md
Normal file
18
Code/aufgabeZwei/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/aufgabeZwei/bin/App.class
Normal file
BIN
Code/aufgabeZwei/bin/App.class
Normal file
Binary file not shown.
41
Code/aufgabeZwei/src/App.java
Normal file
41
Code/aufgabeZwei/src/App.java
Normal file
|
@ -0,0 +1,41 @@
|
|||
// Luca Burger
|
||||
// Aufgabe 2
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
public class App {
|
||||
static Scanner scan = new Scanner(System.in);
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
System.out.println("Wie schwer ist die Sendung (in g)");
|
||||
int gewicht = scan.nextInt();
|
||||
boolean individuelleBriefmarke = false;
|
||||
|
||||
if (gewicht <= 50 && gewicht > 0) {
|
||||
System.out.println("Soll die Sendung versichert werden?");
|
||||
if (versichert.equalsIgnoreCase("j")) {
|
||||
System.out.println("Standartbrief versichert");
|
||||
} else {
|
||||
System.out.println("Standartbrief unversichert");
|
||||
}
|
||||
} else if (gewicht > 50 && gewicht <= 100) {
|
||||
System.out.println("Soll die Sendung versichert werden?");
|
||||
String versichert2 = scan.nextLine();
|
||||
if (versichert2.equalsIgnoreCase("j")) {
|
||||
System.out.println("Kompaktbrief versichert");
|
||||
} else {
|
||||
System.out.println("Kopaktbrief unversichert");
|
||||
}
|
||||
System.out.println("Möchten Sie eine Individuelle Briefmarke?");
|
||||
String frage = scan.nextLine();
|
||||
if (frage.equalsIgnoreCase("j")) {
|
||||
individuelleBriefmarke = true;
|
||||
}
|
||||
} else if (gewicht <= 500) {
|
||||
System.out.println("Grossbrief");
|
||||
} else {
|
||||
System.out.println("Sendung weiterleiten an Paketstation");
|
||||
}
|
||||
System.out.println("BESTEN Dank für die Sendungsaufgabe wir wünschen Ihnen...");
|
||||
}
|
||||
}
|
7
Code/battleShip/.vscode/settings.json
vendored
Normal file
7
Code/battleShip/.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/battleShip/README.md
Normal file
18
Code/battleShip/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/battleShip/bin/App.class
Normal file
BIN
Code/battleShip/bin/App.class
Normal file
Binary file not shown.
BIN
Code/battleShip/bin/test.class
Normal file
BIN
Code/battleShip/bin/test.class
Normal file
Binary file not shown.
581
Code/battleShip/notes/battleShip-V2.pap
Normal file
581
Code/battleShip/notes/battleShip-V2.pap
Normal file
|
@ -0,0 +1,581 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FRAME GUID="2FB25471-B62C-4EE6-BD43-F819C095ACF8" FORMAT="0000" APP_VERSION="2.2.0.8" CHECKSUM="01D27D0A5EE6BF91">
|
||||
<PROJECT FORMAT="1.00" NAME="battleShip-V2" AUTHOR="lucab" CREATED="2024.05.31 17:14:26" MODIFIED="2024.05.31 17:48:36">
|
||||
<DIAGRAMS>
|
||||
<DIAGRAM FORMAT="1.00" ID="0" NAME="Hauptprogramm 1" CREATED="2024.05.31 17:14:43" MODIFIED="2024.05.31 17:27:39">
|
||||
<LAYOUT FORMAT="1.00" COLUMNS="4" ROWS="19">
|
||||
<ENTRIES>
|
||||
<ENTRY COLUMN="0" ROW="14">
|
||||
<FIGURE SUBTYPE="PapModule" FORMAT="1.00" ID="59">
|
||||
<TEXT><![CDATA[hide Ship]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="0" ROW="15">
|
||||
<FIGURE SUBTYPE="PapConnector" FORMAT="1.00" ID="62">
|
||||
<TEXT><![CDATA[]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="0" ANCHOR="True">
|
||||
<FIGURE SUBTYPE="PapTitle" FORMAT="1.00" ID="0">
|
||||
<TEXT><![CDATA[Hauptprogramm 1]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="1">
|
||||
<FIGURE SUBTYPE="PapStart" FORMAT="1.00" ID="1">
|
||||
<TEXT><![CDATA[Start]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="2">
|
||||
<FIGURE SUBTYPE="PapActivity" FORMAT="1.00" ID="4">
|
||||
<TEXT><![CDATA[Board Variables]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="3">
|
||||
<FIGURE SUBTYPE="PapActivity" FORMAT="1.00" ID="6">
|
||||
<TEXT><![CDATA[ship Variables]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="4">
|
||||
<FIGURE SUBTYPE="PapActivity" FORMAT="1.00" ID="8">
|
||||
<TEXT><![CDATA[game Variables]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="5">
|
||||
<FIGURE SUBTYPE="PapModule" FORMAT="1.00" ID="10">
|
||||
<TEXT><![CDATA[initializeGame]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="6">
|
||||
<FIGURE SUBTYPE="PapLoopStart" FORMAT="1.00" ID="12" ASSOCIATE="14">
|
||||
<TEXT><![CDATA[do]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="7">
|
||||
<FIGURE SUBTYPE="PapModule" FORMAT="1.00" ID="16">
|
||||
<TEXT><![CDATA[Printboard]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="8">
|
||||
<FIGURE SUBTYPE="PapOutput" FORMAT="1.00" ID="18">
|
||||
<TEXT><![CDATA[where shoot]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="9">
|
||||
<FIGURE SUBTYPE="PapInput" FORMAT="1.00" ID="20">
|
||||
<TEXT><![CDATA[getCoordinates]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="10">
|
||||
<FIGURE SUBTYPE="PapCondition" FORMAT="1.00" ID="22">
|
||||
<TEXT><![CDATA[input?]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="11">
|
||||
<FIGURE SUBTYPE="PapConnector" FORMAT="1.00" ID="24">
|
||||
<TEXT><![CDATA[]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="12">
|
||||
<FIGURE SUBTYPE="PapConnector" FORMAT="1.00" ID="28">
|
||||
<TEXT><![CDATA[]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="13">
|
||||
<FIGURE SUBTYPE="PapConnector" FORMAT="1.00" ID="57">
|
||||
<TEXT><![CDATA[]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="14">
|
||||
<FIGURE SUBTYPE="PapCondition" FORMAT="1.00" ID="54">
|
||||
<TEXT><![CDATA[are ships revealed?]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="15">
|
||||
<FIGURE SUBTYPE="PapModule" FORMAT="1.00" ID="66">
|
||||
<TEXT><![CDATA[handleShot]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="16">
|
||||
<FIGURE SUBTYPE="PapLoopEnd" FORMAT="1.00" ID="14" ASSOCIATE="12">
|
||||
<TEXT><![CDATA[]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="17">
|
||||
<FIGURE SUBTYPE="PapConnector" FORMAT="1.00" ID="51">
|
||||
<TEXT><![CDATA[]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="18">
|
||||
<FIGURE SUBTYPE="PapEnd" FORMAT="1.00" ID="2">
|
||||
<TEXT><![CDATA[Ende]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="2" ROW="11">
|
||||
<FIGURE SUBTYPE="PapConnector" FORMAT="1.00" ID="26">
|
||||
<TEXT><![CDATA[]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="2" ROW="12">
|
||||
<FIGURE SUBTYPE="PapModule" FORMAT="1.00" ID="34">
|
||||
<TEXT><![CDATA[reveal Ship]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="2" ROW="16">
|
||||
<FIGURE SUBTYPE="PapConnector" FORMAT="1.00" ID="41">
|
||||
<TEXT><![CDATA[]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="3" ROW="11">
|
||||
<FIGURE SUBTYPE="PapConnector" FORMAT="1.00" ID="35">
|
||||
<TEXT><![CDATA[]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="3" ROW="12">
|
||||
<FIGURE SUBTYPE="PapConnector" FORMAT="1.00" ID="37">
|
||||
<TEXT><![CDATA[]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="3" ROW="14">
|
||||
<FIGURE SUBTYPE="PapConnector" FORMAT="1.00" ID="44">
|
||||
<TEXT><![CDATA[]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="3" ROW="16">
|
||||
<FIGURE SUBTYPE="PapOutput" FORMAT="1.00" ID="48">
|
||||
<TEXT><![CDATA[Game has ended]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="3" ROW="17">
|
||||
<FIGURE SUBTYPE="PapConnector" FORMAT="1.00" ID="49">
|
||||
<TEXT><![CDATA[]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
</ENTRIES>
|
||||
</LAYOUT>
|
||||
<CONNECTIONS>
|
||||
<CONNECTION FORMAT="1.00" ID="3" FROM="1" TO="4" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="5" FROM="4" TO="6" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="7" FROM="6" TO="8" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="9" FROM="8" TO="10" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="11" FROM="10" TO="12" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="52" FROM="51" TO="2" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="13" FROM="12" TO="16" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="17" FROM="16" TO="18" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="19" FROM="18" TO="20" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="21" FROM="20" TO="22" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="23" FROM="22" TO="24" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="25" FROM="24" TO="28" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="27" FROM="24" TO="26" TEXT="-1" />
|
||||
<CONNECTION FORMAT="1.00" ID="58" FROM="57" TO="54" TEXT="dafault" />
|
||||
<CONNECTION FORMAT="1.00" ID="31" FROM="28" TO="34" TEXT="?" />
|
||||
<CONNECTION FORMAT="1.00" ID="33" FROM="54" TO="66" TEXT="no" />
|
||||
<CONNECTION FORMAT="1.00" ID="36" FROM="26" TO="35" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="38" FROM="35" TO="37" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="43" FROM="41" TO="14" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="40" FROM="34" TO="41" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="45" FROM="37" TO="44" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="47" FROM="44" TO="48" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="50" FROM="48" TO="49" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="15" FROM="14" TO="51" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="53" FROM="49" TO="51" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="56" FROM="54" TO="59" TEXT="yes" />
|
||||
<CONNECTION FORMAT="1.00" ID="29" FROM="28" TO="57" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="61" FROM="59" TO="62" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="67" FROM="66" TO="14" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="65" FROM="62" TO="66" TEXT="" />
|
||||
</CONNECTIONS>
|
||||
</DIAGRAM>
|
||||
<DIAGRAM FORMAT="1.00" ID="1" NAME="initializeGame" CREATED="2024.05.31 17:17:23" MODIFIED="2024.05.31 17:30:17">
|
||||
<LAYOUT FORMAT="1.00" COLUMNS="2" ROWS="11">
|
||||
<ENTRIES>
|
||||
<ENTRY COLUMN="0" ROW="0" ANCHOR="True">
|
||||
<FIGURE SUBTYPE="PapTitle" FORMAT="1.00" ID="0">
|
||||
<TEXT><![CDATA[initializeGame]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="0" ROW="1">
|
||||
<FIGURE SUBTYPE="PapStart" FORMAT="1.00" ID="1">
|
||||
<TEXT><![CDATA[Start]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="0" ROW="2">
|
||||
<FIGURE SUBTYPE="PapActivity" FORMAT="1.00" ID="4">
|
||||
<TEXT><![CDATA[fill boards with blanks
|
||||
for loop]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="0" ROW="3">
|
||||
<FIGURE SUBTYPE="PapActivity" FORMAT="1.00" ID="6">
|
||||
<TEXT><![CDATA[random coordinates]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="0" ROW="4">
|
||||
<FIGURE SUBTYPE="PapLoopStart" FORMAT="1.00" ID="21" ASSOCIATE="23">
|
||||
<TEXT><![CDATA[for Ship array]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="0" ROW="5">
|
||||
<FIGURE SUBTYPE="PapLoopStart" FORMAT="1.00" ID="8" ASSOCIATE="10">
|
||||
<TEXT><![CDATA[while(!placed)]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="0" ROW="6">
|
||||
<FIGURE SUBTYPE="PapCondition" FORMAT="1.00" ID="12">
|
||||
<TEXT><![CDATA[isValidPlacement?]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="0" ROW="7">
|
||||
<FIGURE SUBTYPE="PapActivity" FORMAT="1.00" ID="19">
|
||||
<TEXT><![CDATA[place Ship]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="0" ROW="8">
|
||||
<FIGURE SUBTYPE="PapLoopEnd" FORMAT="1.00" ID="10" ASSOCIATE="8">
|
||||
<TEXT><![CDATA[]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="0" ROW="9">
|
||||
<FIGURE SUBTYPE="PapLoopEnd" FORMAT="1.00" ID="23" ASSOCIATE="21">
|
||||
<TEXT><![CDATA[]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="0" ROW="10">
|
||||
<FIGURE SUBTYPE="PapEnd" FORMAT="1.00" ID="2">
|
||||
<TEXT><![CDATA[Ende]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="5">
|
||||
<FIGURE SUBTYPE="PapConnector" FORMAT="1.00" ID="16">
|
||||
<TEXT><![CDATA[]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="6">
|
||||
<FIGURE SUBTYPE="PapConnector" FORMAT="1.00" ID="14">
|
||||
<TEXT><![CDATA[]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
</ENTRIES>
|
||||
</LAYOUT>
|
||||
<CONNECTIONS>
|
||||
<CONNECTION FORMAT="1.00" ID="3" FROM="1" TO="4" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="5" FROM="4" TO="6" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="7" FROM="6" TO="21" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="25" FROM="23" TO="2" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="9" FROM="8" TO="12" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="13" FROM="12" TO="19" TEXT="yes" />
|
||||
<CONNECTION FORMAT="1.00" ID="15" FROM="12" TO="14" TEXT="no" />
|
||||
<CONNECTION FORMAT="1.00" ID="17" FROM="14" TO="16" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="18" FROM="16" TO="8" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="20" FROM="19" TO="10" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="11" FROM="10" TO="23" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="22" FROM="21" TO="8" TEXT="" />
|
||||
</CONNECTIONS>
|
||||
</DIAGRAM>
|
||||
<DIAGRAM FORMAT="1.00" ID="2" NAME="Printboard" CREATED="2024.05.31 17:17:45" MODIFIED="2024.05.31 17:36:43">
|
||||
<LAYOUT FORMAT="1.00" COLUMNS="1" ROWS="9">
|
||||
<ENTRIES>
|
||||
<ENTRY COLUMN="0" ROW="0" ANCHOR="True">
|
||||
<FIGURE SUBTYPE="PapTitle" FORMAT="1.00" ID="0">
|
||||
<TEXT><![CDATA[Printboard]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="0" ROW="1">
|
||||
<FIGURE SUBTYPE="PapStart" FORMAT="1.00" ID="1">
|
||||
<TEXT><![CDATA[Start]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="0" ROW="2">
|
||||
<FIGURE SUBTYPE="PapOutput" FORMAT="1.00" ID="4">
|
||||
<TEXT><![CDATA[A | B | C | D | E | F .....]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="0" ROW="3">
|
||||
<FIGURE SUBTYPE="PapOutput" FORMAT="1.00" ID="6">
|
||||
<TEXT><![CDATA[---------------------------------]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="0" ROW="4">
|
||||
<FIGURE SUBTYPE="PapLoopStart" FORMAT="1.00" ID="8" ASSOCIATE="10">
|
||||
<TEXT><![CDATA[for (int i = 0; i < board.length; i++)]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="0" ROW="5">
|
||||
<FIGURE SUBTYPE="PapOutput" FORMAT="1.00" ID="12">
|
||||
<TEXT><![CDATA[board[i][j] |]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="0" ROW="6">
|
||||
<FIGURE SUBTYPE="PapOutput" FORMAT="1.00" ID="14">
|
||||
<TEXT><![CDATA[after 10 fields linebreak]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="0" ROW="7">
|
||||
<FIGURE SUBTYPE="PapLoopEnd" FORMAT="1.00" ID="10" ASSOCIATE="8">
|
||||
<TEXT><![CDATA[]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="0" ROW="8">
|
||||
<FIGURE SUBTYPE="PapEnd" FORMAT="1.00" ID="2">
|
||||
<TEXT><![CDATA[Ende]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
</ENTRIES>
|
||||
</LAYOUT>
|
||||
<CONNECTIONS>
|
||||
<CONNECTION FORMAT="1.00" ID="3" FROM="1" TO="4" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="5" FROM="4" TO="6" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="7" FROM="6" TO="8" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="11" FROM="10" TO="2" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="9" FROM="8" TO="12" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="13" FROM="12" TO="14" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="15" FROM="14" TO="10" TEXT="" />
|
||||
</CONNECTIONS>
|
||||
</DIAGRAM>
|
||||
<DIAGRAM FORMAT="1.00" ID="3" NAME="handleShot" CREATED="2024.05.31 17:26:26" MODIFIED="2024.05.31 17:45:35">
|
||||
<LAYOUT FORMAT="1.00" COLUMNS="3" ROWS="9">
|
||||
<ENTRIES>
|
||||
<ENTRY COLUMN="0" ROW="2">
|
||||
<FIGURE SUBTYPE="PapConnector" FORMAT="1.00" ID="29">
|
||||
<TEXT><![CDATA[]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="0" ROW="6">
|
||||
<FIGURE SUBTYPE="PapConnector" FORMAT="1.00" ID="21">
|
||||
<TEXT><![CDATA[]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="0" ANCHOR="True">
|
||||
<FIGURE SUBTYPE="PapTitle" FORMAT="1.00" ID="0">
|
||||
<TEXT><![CDATA[handleShot]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="1">
|
||||
<FIGURE SUBTYPE="PapStart" FORMAT="1.00" ID="1">
|
||||
<TEXT><![CDATA[Start]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="2">
|
||||
<FIGURE SUBTYPE="PapConnector" FORMAT="1.00" ID="31">
|
||||
<TEXT><![CDATA[]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="3">
|
||||
<FIGURE SUBTYPE="PapActivity" FORMAT="1.00" ID="4">
|
||||
<TEXT><![CDATA[parsing x and y]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="4">
|
||||
<FIGURE SUBTYPE="PapModule" FORMAT="1.00" ID="6">
|
||||
<TEXT><![CDATA[shot]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="5">
|
||||
<FIGURE SUBTYPE="PapCondition" FORMAT="1.00" ID="8">
|
||||
<TEXT><![CDATA[if all ships sunk?]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="6">
|
||||
<FIGURE SUBTYPE="PapCondition" FORMAT="1.00" ID="17">
|
||||
<TEXT><![CDATA[isValidInput?]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="7">
|
||||
<FIGURE SUBTYPE="PapConnector" FORMAT="1.00" ID="14">
|
||||
<TEXT><![CDATA[]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="8">
|
||||
<FIGURE SUBTYPE="PapEnd" FORMAT="1.00" ID="2">
|
||||
<TEXT><![CDATA[Ende]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="2" ROW="5">
|
||||
<FIGURE SUBTYPE="PapActivity" FORMAT="1.00" ID="10">
|
||||
<TEXT><![CDATA[end gane]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="2" ROW="7">
|
||||
<FIGURE SUBTYPE="PapConnector" FORMAT="1.00" ID="12">
|
||||
<TEXT><![CDATA[]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
</ENTRIES>
|
||||
</LAYOUT>
|
||||
<CONNECTIONS>
|
||||
<CONNECTION FORMAT="1.00" ID="32" FROM="31" TO="4" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="5" FROM="4" TO="6" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="7" FROM="6" TO="8" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="15" FROM="14" TO="2" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="11" FROM="8" TO="10" TEXT="yes" />
|
||||
<CONNECTION FORMAT="1.00" ID="13" FROM="10" TO="12" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="9" FROM="8" TO="17" TEXT="no" />
|
||||
<CONNECTION FORMAT="1.00" ID="16" FROM="12" TO="14" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="18" FROM="17" TO="14" TEXT="yes" />
|
||||
<CONNECTION FORMAT="1.00" ID="22" FROM="17" TO="21" TEXT="no" />
|
||||
<CONNECTION FORMAT="1.00" ID="3" FROM="1" TO="31" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="24" FROM="21" TO="29" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="33" FROM="29" TO="31" TEXT="" />
|
||||
</CONNECTIONS>
|
||||
</DIAGRAM>
|
||||
<DIAGRAM FORMAT="1.00" ID="4" NAME="shot" CREATED="2024.05.31 17:37:30" MODIFIED="2024.05.31 17:37:30">
|
||||
<LAYOUT FORMAT="1.00" COLUMNS="4" ROWS="10">
|
||||
<ENTRIES>
|
||||
<ENTRY COLUMN="0" ROW="2">
|
||||
<FIGURE SUBTYPE="PapConnector" FORMAT="1.00" ID="73">
|
||||
<TEXT><![CDATA[]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="0" ROW="7">
|
||||
<FIGURE SUBTYPE="PapConnector" FORMAT="1.00" ID="71">
|
||||
<TEXT><![CDATA[]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="0" ANCHOR="True">
|
||||
<FIGURE SUBTYPE="PapTitle" FORMAT="1.00" ID="0">
|
||||
<TEXT><![CDATA[shot]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="1">
|
||||
<FIGURE SUBTYPE="PapStart" FORMAT="1.00" ID="1">
|
||||
<TEXT><![CDATA[Start]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="2">
|
||||
<FIGURE SUBTYPE="PapCondition" FORMAT="1.00" ID="4">
|
||||
<TEXT><![CDATA[board[y][x]?]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="3">
|
||||
<FIGURE SUBTYPE="PapConnector" FORMAT="1.00" ID="6">
|
||||
<TEXT><![CDATA[]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="4">
|
||||
<FIGURE SUBTYPE="PapConnector" FORMAT="1.00" ID="10">
|
||||
<TEXT><![CDATA[]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="5">
|
||||
<FIGURE SUBTYPE="PapConnector" FORMAT="1.00" ID="14">
|
||||
<TEXT><![CDATA[]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="6">
|
||||
<FIGURE SUBTYPE="PapConnector" FORMAT="1.00" ID="18">
|
||||
<TEXT><![CDATA[]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="8">
|
||||
<FIGURE SUBTYPE="PapConnector" FORMAT="1.00" ID="68">
|
||||
<TEXT><![CDATA[]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="9">
|
||||
<FIGURE SUBTYPE="PapEnd" FORMAT="1.00" ID="2">
|
||||
<TEXT><![CDATA[Ende]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="2" ROW="3">
|
||||
<FIGURE SUBTYPE="PapOutput" FORMAT="1.00" ID="22">
|
||||
<TEXT><![CDATA[Miss]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="2" ROW="4">
|
||||
<FIGURE SUBTYPE="PapOutput" FORMAT="1.00" ID="23">
|
||||
<TEXT><![CDATA[Already shot this field]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="2" ROW="5">
|
||||
<FIGURE SUBTYPE="PapModule" FORMAT="1.00" ID="24">
|
||||
<TEXT><![CDATA[isShipSunk]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="2" ROW="6">
|
||||
<FIGURE SUBTYPE="PapOutput" FORMAT="1.00" ID="25">
|
||||
<TEXT><![CDATA[invalidInput]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="2" ROW="7">
|
||||
<FIGURE SUBTYPE="PapConnector" FORMAT="1.00" ID="52">
|
||||
<TEXT><![CDATA[]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="3" ROW="3">
|
||||
<FIGURE SUBTYPE="PapConnector" FORMAT="1.00" ID="30">
|
||||
<TEXT><![CDATA[]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="3" ROW="4">
|
||||
<FIGURE SUBTYPE="PapConnector" FORMAT="1.00" ID="28">
|
||||
<TEXT><![CDATA[]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="3" ROW="5">
|
||||
<FIGURE SUBTYPE="PapConnector" FORMAT="1.00" ID="26">
|
||||
<TEXT><![CDATA[]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="3" ROW="6">
|
||||
<FIGURE SUBTYPE="PapConnector" FORMAT="1.00" ID="75">
|
||||
<TEXT><![CDATA[]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="3" ROW="8">
|
||||
<FIGURE SUBTYPE="PapConnector" FORMAT="1.00" ID="66">
|
||||
<TEXT><![CDATA[]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
</ENTRIES>
|
||||
</LAYOUT>
|
||||
<CONNECTIONS>
|
||||
<CONNECTION FORMAT="1.00" ID="3" FROM="1" TO="4" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="5" FROM="4" TO="6" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="7" FROM="6" TO="10" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="9" FROM="6" TO="22" TEXT="BLANK" />
|
||||
<CONNECTION FORMAT="1.00" ID="11" FROM="10" TO="14" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="13" FROM="10" TO="23" TEXT="WATER" />
|
||||
<CONNECTION FORMAT="1.00" ID="15" FROM="14" TO="18" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="17" FROM="14" TO="24" TEXT="HIDDEN_SHIP || REVEALED_SHIP" />
|
||||
<CONNECTION FORMAT="1.00" ID="69" FROM="68" TO="2" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="21" FROM="18" TO="25" TEXT="default" />
|
||||
<CONNECTION FORMAT="1.00" ID="27" FROM="24" TO="26" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="29" FROM="23" TO="28" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="31" FROM="22" TO="30" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="32" FROM="30" TO="28" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="33" FROM="28" TO="26" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="35" FROM="26" TO="75" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="74" FROM="71" TO="73" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="76" FROM="75" TO="66" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="53" FROM="25" TO="52" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="55" FROM="52" TO="71" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="70" FROM="66" TO="68" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="77" FROM="73" TO="4" TEXT="" />
|
||||
</CONNECTIONS>
|
||||
</DIAGRAM>
|
||||
<DIAGRAM FORMAT="1.00" ID="5" NAME="isShipSunk" CREATED="2024.05.31 17:47:28" MODIFIED="2024.05.31 17:47:28">
|
||||
<LAYOUT FORMAT="1.00" COLUMNS="1" ROWS="3">
|
||||
<ENTRIES>
|
||||
<ENTRY COLUMN="0" ROW="0" ANCHOR="True">
|
||||
<FIGURE SUBTYPE="PapTitle" FORMAT="1.00" ID="0">
|
||||
<TEXT><![CDATA[isShipSunk]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="0" ROW="1">
|
||||
<FIGURE SUBTYPE="PapStart" FORMAT="1.00" ID="1">
|
||||
<TEXT><![CDATA[Start]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="0" ROW="2">
|
||||
<FIGURE SUBTYPE="PapEnd" FORMAT="1.00" ID="2">
|
||||
<TEXT><![CDATA[Ende]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
</ENTRIES>
|
||||
</LAYOUT>
|
||||
<CONNECTIONS>
|
||||
<CONNECTION FORMAT="1.00" ID="3" FROM="1" TO="2" TEXT="" />
|
||||
</CONNECTIONS>
|
||||
</DIAGRAM>
|
||||
</DIAGRAMS>
|
||||
</PROJECT>
|
||||
</FRAME>
|
377
Code/battleShip/notes/battleShip.pap
Normal file
377
Code/battleShip/notes/battleShip.pap
Normal file
|
@ -0,0 +1,377 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FRAME GUID="2FB25471-B62C-4EE6-BD43-F819C095ACF8" FORMAT="0000" APP_VERSION="2.2.0.8" CHECKSUM="D412268247A94E79">
|
||||
<PROJECT FORMAT="1.00" NAME="battleShip" AUTHOR="lucab" CREATED="2024.04.03 14:35:24" MODIFIED="2024.04.04 07:58:33">
|
||||
<DIAGRAMS>
|
||||
<DIAGRAM FORMAT="1.00" ID="0" NAME="Hauptprogramm 1" CREATED="2024.04.03 14:35:29" MODIFIED="2024.04.03 14:48:22">
|
||||
<LAYOUT FORMAT="1.00" COLUMNS="6" ROWS="24">
|
||||
<ENTRIES>
|
||||
<ENTRY COLUMN="0" ROW="5">
|
||||
<FIGURE SUBTYPE="PapConnector" FORMAT="1.00" ID="99">
|
||||
<TEXT><![CDATA[]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="0" ROW="9">
|
||||
<FIGURE SUBTYPE="PapOutput" FORMAT="1.00" ID="92">
|
||||
<TEXT><![CDATA[Invalid Input]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="0" ROW="13">
|
||||
<FIGURE SUBTYPE="PapConnector" FORMAT="1.00" ID="82">
|
||||
<TEXT><![CDATA[]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="0" ANCHOR="True">
|
||||
<FIGURE SUBTYPE="PapTitle" FORMAT="1.00" ID="0">
|
||||
<TEXT><![CDATA[Hauptprogramm 1]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="1">
|
||||
<FIGURE SUBTYPE="PapStart" FORMAT="1.00" ID="1">
|
||||
<TEXT><![CDATA[Start]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="2">
|
||||
<FIGURE SUBTYPE="PapOutput" FORMAT="1.00" ID="4">
|
||||
<TEXT><![CDATA[Explanation Game]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="3">
|
||||
<FIGURE SUBTYPE="PapModule" FORMAT="1.00" ID="6">
|
||||
<TEXT><![CDATA[initializeGame]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="4">
|
||||
<FIGURE SUBTYPE="PapLoopStart" FORMAT="1.00" ID="8" ASSOCIATE="10">
|
||||
<TEXT><![CDATA[gameloop]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="5">
|
||||
<FIGURE SUBTYPE="PapLoopStart" FORMAT="1.00" ID="43" ASSOCIATE="45">
|
||||
<TEXT><![CDATA[PlayerInput]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="6">
|
||||
<FIGURE SUBTYPE="PapOutput" FORMAT="1.00" ID="12">
|
||||
<TEXT><![CDATA[Where do you want to shoot]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="7">
|
||||
<FIGURE SUBTYPE="PapInput" FORMAT="1.00" ID="14">
|
||||
<TEXT><![CDATA[coordinates]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="8">
|
||||
<FIGURE SUBTYPE="PapCondition" FORMAT="1.00" ID="16">
|
||||
<TEXT><![CDATA[coordinaten]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="9">
|
||||
<FIGURE SUBTYPE="PapConnector" FORMAT="1.00" ID="18">
|
||||
<TEXT><![CDATA[]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="10">
|
||||
<FIGURE SUBTYPE="PapConnector" FORMAT="1.00" ID="22">
|
||||
<TEXT><![CDATA[]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="11">
|
||||
<FIGURE SUBTYPE="PapConnector" FORMAT="1.00" ID="48">
|
||||
<TEXT><![CDATA[]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="12">
|
||||
<FIGURE SUBTYPE="PapConnector" FORMAT="1.00" ID="61">
|
||||
<TEXT><![CDATA[]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="13">
|
||||
<FIGURE SUBTYPE="PapCondition" FORMAT="1.00" ID="80">
|
||||
<TEXT><![CDATA[If valid]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="14">
|
||||
<FIGURE SUBTYPE="PapCondition" FORMAT="1.00" ID="102">
|
||||
<TEXT><![CDATA[Ship?]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="15">
|
||||
<FIGURE SUBTYPE="PapOutput" FORMAT="1.00" ID="109">
|
||||
<TEXT><![CDATA[x/x is water]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="16">
|
||||
<FIGURE SUBTYPE="PapConnector" FORMAT="1.00" ID="127">
|
||||
<TEXT><![CDATA[]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="17">
|
||||
<FIGURE SUBTYPE="PapConnector" FORMAT="1.00" ID="131">
|
||||
<TEXT><![CDATA[]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="18">
|
||||
<FIGURE SUBTYPE="PapCondition" FORMAT="1.00" ID="140">
|
||||
<TEXT><![CDATA[all ship sunk?]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="19">
|
||||
<FIGURE SUBTYPE="PapOutput" FORMAT="1.00" ID="125">
|
||||
<TEXT><![CDATA[board]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="20">
|
||||
<FIGURE SUBTYPE="PapActivity" FORMAT="1.00" ID="146">
|
||||
<TEXT><![CDATA[shot ++]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="21">
|
||||
<FIGURE SUBTYPE="PapLoopEnd" FORMAT="1.00" ID="45" ASSOCIATE="43">
|
||||
<TEXT><![CDATA[]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="22">
|
||||
<FIGURE SUBTYPE="PapLoopEnd" FORMAT="1.00" ID="10" ASSOCIATE="8">
|
||||
<TEXT><![CDATA[]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="23">
|
||||
<FIGURE SUBTYPE="PapEnd" FORMAT="1.00" ID="2">
|
||||
<TEXT><![CDATA[Ende]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="2" ROW="11">
|
||||
<FIGURE SUBTYPE="PapConnector" FORMAT="1.00" ID="28">
|
||||
<TEXT><![CDATA[]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="2" ROW="14">
|
||||
<FIGURE SUBTYPE="PapCondition" FORMAT="1.00" ID="111">
|
||||
<TEXT><![CDATA[is ship alive?]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="2" ROW="15">
|
||||
<FIGURE SUBTYPE="PapOutput" FORMAT="1.00" ID="120">
|
||||
<TEXT><![CDATA[ship sunk]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="2" ROW="17">
|
||||
<FIGURE SUBTYPE="PapActivity" FORMAT="1.00" ID="122">
|
||||
<TEXT><![CDATA[Water around ship]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="3" ROW="9">
|
||||
<FIGURE SUBTYPE="PapActivity" FORMAT="1.00" ID="30">
|
||||
<TEXT><![CDATA[gameEnd]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="3" ROW="10">
|
||||
<FIGURE SUBTYPE="PapActivity" FORMAT="1.00" ID="31">
|
||||
<TEXT><![CDATA[giveTip]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="3" ROW="11">
|
||||
<FIGURE SUBTYPE="PapActivity" FORMAT="1.00" ID="34">
|
||||
<TEXT><![CDATA[validateInput]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="3" ROW="14">
|
||||
<FIGURE SUBTYPE="PapOutput" FORMAT="1.00" ID="124">
|
||||
<TEXT><![CDATA[ship hit on x/y]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="3" ROW="16">
|
||||
<FIGURE SUBTYPE="PapConnector" FORMAT="1.00" ID="137">
|
||||
<TEXT><![CDATA[]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="3" ROW="18">
|
||||
<FIGURE SUBTYPE="PapOutput" FORMAT="1.00" ID="144">
|
||||
<TEXT><![CDATA[You won the game in x shots!]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="4" ROW="10">
|
||||
<FIGURE SUBTYPE="PapConnector" FORMAT="1.00" ID="36">
|
||||
<TEXT><![CDATA[]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="4" ROW="11">
|
||||
<FIGURE SUBTYPE="PapConnector" FORMAT="1.00" ID="38">
|
||||
<TEXT><![CDATA[]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="4" ROW="12">
|
||||
<FIGURE SUBTYPE="PapConnector" FORMAT="1.00" ID="41">
|
||||
<TEXT><![CDATA[]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="5" ROW="9">
|
||||
<FIGURE SUBTYPE="PapConnector" FORMAT="1.00" ID="63">
|
||||
<TEXT><![CDATA[]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="5" ROW="18">
|
||||
<FIGURE SUBTYPE="PapConnector" FORMAT="1.00" ID="141">
|
||||
<TEXT><![CDATA[]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="5" ROW="22">
|
||||
<FIGURE SUBTYPE="PapConnector" FORMAT="1.00" ID="75">
|
||||
<TEXT><![CDATA[]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
</ENTRIES>
|
||||
</LAYOUT>
|
||||
<CONNECTIONS>
|
||||
<CONNECTION FORMAT="1.00" ID="3" FROM="1" TO="4" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="5" FROM="4" TO="6" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="7" FROM="6" TO="8" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="79" FROM="75" TO="10" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="9" FROM="8" TO="43" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="13" FROM="12" TO="14" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="23" FROM="22" TO="48" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="17" FROM="16" TO="18" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="19" FROM="18" TO="22" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="21" FROM="18" TO="30" TEXT="-1" />
|
||||
<CONNECTION FORMAT="1.00" ID="50" FROM="48" TO="28" TEXT="else" />
|
||||
<CONNECTION FORMAT="1.00" ID="52" FROM="61" TO="80" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="27" FROM="22" TO="31" TEXT="?" />
|
||||
<CONNECTION FORMAT="1.00" ID="25" FROM="45" TO="10" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="130" FROM="140" TO="125" TEXT="no" />
|
||||
<CONNECTION FORMAT="1.00" ID="35" FROM="28" TO="34" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="37" FROM="31" TO="36" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="39" FROM="34" TO="38" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="40" FROM="36" TO="38" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="42" FROM="38" TO="41" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="15" FROM="14" TO="16" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="44" FROM="43" TO="12" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="49" FROM="48" TO="61" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="54" FROM="41" TO="61" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="33" FROM="30" TO="63" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="142" FROM="141" TO="75" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="78" FROM="10" TO="2" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="81" FROM="80" TO="102" TEXT="yes" />
|
||||
<CONNECTION FORMAT="1.00" ID="83" FROM="80" TO="82" TEXT="no" />
|
||||
<CONNECTION FORMAT="1.00" ID="101" FROM="99" TO="43" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="85" FROM="82" TO="92" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="94" FROM="92" TO="99" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="103" FROM="102" TO="109" TEXT="no" />
|
||||
<CONNECTION FORMAT="1.00" ID="110" FROM="109" TO="127" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="106" FROM="102" TO="111" TEXT="yes" />
|
||||
<CONNECTION FORMAT="1.00" ID="114" FROM="111" TO="124" TEXT="yes" />
|
||||
<CONNECTION FORMAT="1.00" ID="119" FROM="111" TO="120" TEXT="no" />
|
||||
<CONNECTION FORMAT="1.00" ID="121" FROM="120" TO="122" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="126" FROM="125" TO="146" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="132" FROM="131" TO="140" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="128" FROM="127" TO="131" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="133" FROM="122" TO="131" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="139" FROM="137" TO="127" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="136" FROM="124" TO="137" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="66" FROM="63" TO="141" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="143" FROM="140" TO="144" TEXT="yes" />
|
||||
<CONNECTION FORMAT="1.00" ID="145" FROM="144" TO="141" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="147" FROM="146" TO="45" TEXT="" />
|
||||
</CONNECTIONS>
|
||||
</DIAGRAM>
|
||||
<DIAGRAM FORMAT="1.00" ID="1" NAME="initializeGame" CREATED="2024.04.03 14:36:11" MODIFIED="2024.04.04 07:58:33">
|
||||
<LAYOUT FORMAT="1.00" COLUMNS="2" ROWS="12">
|
||||
<ENTRIES>
|
||||
<ENTRY COLUMN="0" ROW="0" ANCHOR="True">
|
||||
<FIGURE SUBTYPE="PapTitle" FORMAT="1.00" ID="0">
|
||||
<TEXT><![CDATA[initializeGame]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="0" ROW="1">
|
||||
<FIGURE SUBTYPE="PapStart" FORMAT="1.00" ID="1">
|
||||
<TEXT><![CDATA[Start]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="0" ROW="2">
|
||||
<FIGURE SUBTYPE="PapActivity" FORMAT="1.00" ID="15">
|
||||
<TEXT><![CDATA[Initialize board (2d boolean array 10x10)]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="0" ROW="3">
|
||||
<FIGURE SUBTYPE="PapActivity" FORMAT="1.00" ID="17">
|
||||
<TEXT><![CDATA[set ships]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="0" ROW="4">
|
||||
<FIGURE SUBTYPE="PapComment" FORMAT="1.00" ID="19">
|
||||
<TEXT><![CDATA[1 | 4er | 1
|
||||
2 | 3er | 2, 3
|
||||
3 | 2er | 4, 5, 6
|
||||
4 | 1er | 7, 8, 9, 10]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="0" ROW="5">
|
||||
<FIGURE SUBTYPE="PapLoopStart" FORMAT="1.00" ID="6" ASSOCIATE="8">
|
||||
<TEXT><![CDATA[place ship x]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="0" ROW="6">
|
||||
<FIGURE SUBTYPE="PapActivity" FORMAT="1.00" ID="4">
|
||||
<TEXT><![CDATA[Random Placement of ship x]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="0" ROW="7">
|
||||
<FIGURE SUBTYPE="PapCondition" FORMAT="1.00" ID="20">
|
||||
<TEXT><![CDATA[Is the placement valid?]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="0" ROW="8">
|
||||
<FIGURE SUBTYPE="PapActivity" FORMAT="1.00" ID="31">
|
||||
<TEXT><![CDATA[place]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="0" ROW="9">
|
||||
<FIGURE SUBTYPE="PapActivity" FORMAT="1.00" ID="11">
|
||||
<TEXT><![CDATA[x++]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="0" ROW="10">
|
||||
<FIGURE SUBTYPE="PapLoopEnd" FORMAT="1.00" ID="8" ASSOCIATE="6">
|
||||
<TEXT><![CDATA[]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="0" ROW="11">
|
||||
<FIGURE SUBTYPE="PapEnd" FORMAT="1.00" ID="2">
|
||||
<TEXT><![CDATA[Ende]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="5">
|
||||
<FIGURE SUBTYPE="PapConnector" FORMAT="1.00" ID="26">
|
||||
<TEXT><![CDATA[]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="6">
|
||||
<FIGURE SUBTYPE="PapActivity" FORMAT="1.00" ID="29">
|
||||
<TEXT><![CDATA[dont place]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
<ENTRY COLUMN="1" ROW="7">
|
||||
<FIGURE SUBTYPE="PapConnector" FORMAT="1.00" ID="22">
|
||||
<TEXT><![CDATA[]]></TEXT>
|
||||
</FIGURE>
|
||||
</ENTRY>
|
||||
</ENTRIES>
|
||||
</LAYOUT>
|
||||
<CONNECTIONS>
|
||||
<CONNECTION FORMAT="1.00" ID="16" FROM="15" TO="17" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="10" FROM="8" TO="2" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="5" FROM="4" TO="20" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="7" FROM="6" TO="4" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="12" FROM="11" TO="8" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="3" FROM="1" TO="15" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="18" FROM="17" TO="6" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="21" FROM="20" TO="31" TEXT="yes" />
|
||||
<CONNECTION FORMAT="1.00" ID="23" FROM="20" TO="22" TEXT="no" />
|
||||
<CONNECTION FORMAT="1.00" ID="28" FROM="26" TO="6" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="25" FROM="22" TO="29" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="30" FROM="29" TO="26" TEXT="" />
|
||||
<CONNECTION FORMAT="1.00" ID="32" FROM="31" TO="11" TEXT="" />
|
||||
</CONNECTIONS>
|
||||
</DIAGRAM>
|
||||
</DIAGRAMS>
|
||||
</PROJECT>
|
||||
</FRAME>
|
44
Code/battleShip/notes/board.txt
Normal file
44
Code/battleShip/notes/board.txt
Normal file
|
@ -0,0 +1,44 @@
|
|||
| A | B | C | D | E | F | G | H | I | J |
|
||||
--------------------------------------------
|
||||
1 | | | | | | | | | | |
|
||||
--------------------------------------------
|
||||
2 | | | | | | | | | | |
|
||||
--------------------------------------------
|
||||
3 | | | | | | | | | | |
|
||||
--------------------------------------------
|
||||
4 | | | | | | | | | | |
|
||||
--------------------------------------------
|
||||
5 | | | | | | | | | | |
|
||||
--------------------------------------------
|
||||
6 | | | | | | | | | | |
|
||||
--------------------------------------------
|
||||
7 | | | | | | | | | | |
|
||||
--------------------------------------------
|
||||
8 | | | | | | | | | | |
|
||||
--------------------------------------------
|
||||
9 | | | | | | | | | | |
|
||||
--------------------------------------------
|
||||
10 | | | | | | | | | | |
|
||||
--------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
| | | | | | | | | | .
|
BIN
Code/battleShip/src/App.class
Normal file
BIN
Code/battleShip/src/App.class
Normal file
Binary file not shown.
349
Code/battleShip/src/App.java
Normal file
349
Code/battleShip/src/App.java
Normal file
|
@ -0,0 +1,349 @@
|
|||
import java.util.Random;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class App {
|
||||
// Board chars
|
||||
public static final int BLANK = 0; // ' '
|
||||
public static final int WATER = 1; // 'O'
|
||||
public static final int SHIP = 2; // 'X'
|
||||
public static final int SUNK = 3; // 'S'
|
||||
public static final int HIDDEN_SHIP = 4; // ' '
|
||||
public static final int REVEALED_SHIP = 5; // 'R'
|
||||
|
||||
// board[vertical desc --> y][horizontal left to right --> x]
|
||||
public static int[][] board = new int[10][10];
|
||||
|
||||
// Array where the ships are stored
|
||||
private static int[] shipX = new int[10];
|
||||
private static int[] shipY = new int[10];
|
||||
private static boolean[] shipDirection = new boolean[10];
|
||||
private static int[] shipLength = new int[10];
|
||||
|
||||
// Number of shots fired
|
||||
public static int firedShot = 0;
|
||||
public static boolean game = true;
|
||||
|
||||
public static void main(String[] args) {
|
||||
boolean areShipsRevealed = false;
|
||||
// Explanation rules
|
||||
initializeGame();
|
||||
do {
|
||||
printBoard();
|
||||
System.out.println("Where do you want to shoot? (e.g., A5 or ? for a tip or -1 to end the game) ");
|
||||
String input = getCoordinates();
|
||||
|
||||
switch (input) {
|
||||
case "-1":
|
||||
game = false;
|
||||
break;
|
||||
case "?":
|
||||
revealHiddenShips();
|
||||
areShipsRevealed = true;
|
||||
break;
|
||||
default:
|
||||
// The Lines 47-49 should be deactivated while debugging to make it easier
|
||||
if (areShipsRevealed) {
|
||||
hideRevealedShips();
|
||||
}
|
||||
handleShot(input);
|
||||
break;
|
||||
}
|
||||
} while (game);
|
||||
}
|
||||
|
||||
// Handles the player's shot input, validates it, and processes the shot.
|
||||
private static void handleShot(String input) {
|
||||
try {
|
||||
char xChar = input.toLowerCase().charAt(0);
|
||||
int y = Integer.parseInt(input.substring(1)) - 1;
|
||||
int x = xChar - 'a';
|
||||
if (isInputValid(x, y)) {
|
||||
String result = shot(x, y);
|
||||
System.out.println(result);
|
||||
System.out.println("Number of fired shots: " + firedShot);
|
||||
if (allShipSunk()) {
|
||||
printBoard();
|
||||
System.out.println("All ships have been sunk" + "\nYou won the game\n");
|
||||
printBoard();
|
||||
game = false;
|
||||
}
|
||||
} else {
|
||||
System.out.println("Invalid input. Please enter a valid coordinate (e.g., A5).");
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
System.out.println("Invalid input format. Please enter a valid coordinate (e.g., A5).");
|
||||
}
|
||||
}
|
||||
|
||||
// Reveals the positions of hidden ships on the board.
|
||||
private static void revealHiddenShips() {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
for (int j = 0; j < 10; j++) {
|
||||
if (board[i][j] == HIDDEN_SHIP) {
|
||||
board[i][j] = REVEALED_SHIP;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Hides the previously revealed ships on the board.
|
||||
private static void hideRevealedShips() {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
for (int j = 0; j < 10; j++) {
|
||||
if (board[i][j] == REVEALED_SHIP) {
|
||||
board[i][j] = HIDDEN_SHIP;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Initializes the game by setting up the board and randomly placing ships.
|
||||
private static void initializeGame() {
|
||||
// Fill board with blanks
|
||||
for (int i = 0; i < board.length; i++) {
|
||||
for (int j = 0; j < board[i].length; j++) {
|
||||
board[i][j] = BLANK;
|
||||
}
|
||||
}
|
||||
|
||||
// Place ships randomly
|
||||
Random random = new Random();
|
||||
int i = 0;
|
||||
int[] ships = { 4, 3, 3, 2, 2, 2, 1, 1, 1, 1 };
|
||||
for (int shipSize : ships) {
|
||||
boolean placed = false;
|
||||
while (!placed) {
|
||||
int x = random.nextInt(10);
|
||||
int y = random.nextInt(10);
|
||||
boolean direction = random.nextBoolean();
|
||||
if (isValidPlacement(x, y, shipSize, direction)) {
|
||||
shipLength[i] = shipSize;
|
||||
shipX[i] = x;
|
||||
shipY[i] = y;
|
||||
shipDirection[i] = direction;
|
||||
|
||||
i++;
|
||||
placeShip(x, y, shipSize, direction);
|
||||
placed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Validates the placement of a ship on the board.
|
||||
private static boolean isValidPlacement(int x, int y, int shipSize, boolean direction) {
|
||||
if (!isWithinBounds(x, y, shipSize, direction)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (doesOverlap(x, y, shipSize, direction)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return hasSpaceOfWater(x, y, shipSize, direction);
|
||||
}
|
||||
|
||||
// Checks if the ship placement is within the board boundaries.
|
||||
private static boolean isWithinBounds(int x, int y, int shipSize, boolean direction) {
|
||||
if (direction) {
|
||||
return x >= 0 && x + shipSize <= 10 && y >= 0 && y < 10;
|
||||
} else {
|
||||
return y >= 0 && y + shipSize <= 10 && x >= 0 && x < 10;
|
||||
}
|
||||
}
|
||||
|
||||
// Checks if the ship placement overlaps with existing ships.
|
||||
private static boolean doesOverlap(int x, int y, int shipSize, boolean direction) {
|
||||
for (int i = 0; i < shipSize; i++) {
|
||||
int row = direction ? y : y + i;
|
||||
int col = direction ? x + i : x;
|
||||
|
||||
if (board[row][col] != BLANK) {
|
||||
return true; // Overlaps with existing ship
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Ensures that the ship has a space of water around it.
|
||||
private static boolean hasSpaceOfWater(int x, int y, int shipSize, boolean direction) {
|
||||
for (int i = 0; i < shipSize; i++) {
|
||||
int row = direction ? y : y + i;
|
||||
int col = direction ? x + i : x;
|
||||
|
||||
for (int j = row - 1; j <= row + 1; j++) {
|
||||
for (int k = col - 1; k <= col + 1; k++) {
|
||||
if (j >= 0 && j < 10 && k >= 0 && k < 10 && board[j][k] != BLANK) {
|
||||
return false; // Adjacent cell is not water
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true; // Has space of water
|
||||
}
|
||||
|
||||
// Places a ship on the board at the specified coordinates.
|
||||
private static void placeShip(int x, int y, int shipSize, boolean direction) {
|
||||
if (direction) {
|
||||
for (int i = 0; i < shipSize; i++) {
|
||||
board[y][x + i] = HIDDEN_SHIP;
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < shipSize; i++) {
|
||||
board[y + i][x] = HIDDEN_SHIP;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Gets coordinates input from the user.
|
||||
private static String getCoordinates() {
|
||||
Scanner scan = new Scanner(System.in);
|
||||
return scan.next();
|
||||
}
|
||||
|
||||
// Validates the input coordinates.
|
||||
private static boolean isInputValid(int x, int y) {
|
||||
return x >= 0 && x < 10 && y >= 0 && y < 10;
|
||||
}
|
||||
|
||||
// Processes a shot at the specified coordinates and returns the result.
|
||||
private static String shot(int x, int y) {
|
||||
switch (board[y][x]) {
|
||||
case BLANK:
|
||||
board[y][x] = WATER;
|
||||
firedShot++;
|
||||
return "Miss!";
|
||||
case WATER:
|
||||
return "Already shot this field!";
|
||||
case HIDDEN_SHIP:
|
||||
case REVEALED_SHIP:
|
||||
board[y][x] = SHIP;
|
||||
firedShot++;
|
||||
if (isShipSunk(x, y)) {
|
||||
sinkShip(x, y);
|
||||
return "You sunk a ship!";
|
||||
} else {
|
||||
return "You hit a ship!";
|
||||
}
|
||||
default:
|
||||
return "Invalid state!";
|
||||
}
|
||||
}
|
||||
|
||||
// Sinks a ship by marking all its parts as sunk.
|
||||
private static void sinkShip(int x, int y) {
|
||||
for (int i = 0; i < shipX.length; i++) {
|
||||
int startX = shipX[i];
|
||||
int startY = shipY[i];
|
||||
int length = shipLength[i];
|
||||
boolean direction = shipDirection[i]; // true for horizontal, false for vertical
|
||||
|
||||
// Check if the current shot is part of this ship
|
||||
if (direction) {
|
||||
// Horizontal ship
|
||||
if (y == startY && x >= startX && x < startX + length) {
|
||||
// Mark all parts of the ship as sunk
|
||||
for (int j = 0; j < length; j++) {
|
||||
board[startY][startX + j] = SUNK;
|
||||
}
|
||||
|
||||
for (int j = 0; j < length; j++) {
|
||||
placeWaterAroundShip(startX + j, startY);
|
||||
}
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// Vertical ship
|
||||
if (x == startX && y >= startY && y < startY + length) {
|
||||
// Mark all parts of the ship as sunk
|
||||
for (int j = 0; j < length; j++) {
|
||||
board[startY + j][startX] = SUNK;
|
||||
}
|
||||
|
||||
for (int j = 0; j < length; j++) {
|
||||
placeWaterAroundShip(startX, startY + j);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Checks if a ship at the specified coordinates is completely sunk.
|
||||
private static boolean isShipSunk(int x, int y) {
|
||||
for (int i = 0; i < shipX.length; i++) {
|
||||
int startX = shipX[i];
|
||||
int startY = shipY[i];
|
||||
int length = shipLength[i];
|
||||
boolean direction = shipDirection[i]; // true for horizontal, false for vertical
|
||||
|
||||
// Check if the current shot is part of this ship
|
||||
if (direction) {
|
||||
// Horizontal ship
|
||||
if (y == startY && x >= startX && x < startX + length) {
|
||||
// Check all parts of the ship
|
||||
for (int j = 0; j < length; j++) {
|
||||
if (board[startY][startX + j] != SHIP && board[startY][startX + j] != SUNK) {
|
||||
return false; // If any part is not hit, the ship is not sunk
|
||||
}
|
||||
}
|
||||
return true; // All parts are hit, the ship is sunk
|
||||
}
|
||||
} else {
|
||||
// Vertical ship
|
||||
if (x == startX && y >= startY && y < startY + length) {
|
||||
// Check all parts of the ship
|
||||
for (int j = 0; j < length; j++) {
|
||||
if (board[startY + j][startX] != SHIP && board[startY + j][startX] != SUNK) {
|
||||
return false; // If any part is not hit, the ship is not sunk
|
||||
}
|
||||
}
|
||||
return true; // All parts are hit, the ship is sunk
|
||||
}
|
||||
}
|
||||
}
|
||||
return false; // If the shot is not part of any ship (shouldn't happen in a valid game)
|
||||
}
|
||||
|
||||
// Prints the current state of the board to the console.
|
||||
private static void printBoard() {
|
||||
System.out.println(" | A | B | C | D | E | F | G | H | I | J |");
|
||||
System.out.println("--------------------------------------------");
|
||||
char[] symbols = { ' ', 'O', 'X', 'S', ' ', 'R' };
|
||||
|
||||
for (int i = 0; i < board.length; i++) {
|
||||
if (i < 9) {
|
||||
System.out.print(" " + (i + 1) + " |");
|
||||
} else {
|
||||
System.out.print(" " + (i + 1) + "|");
|
||||
}
|
||||
for (int j = 0; j < board[i].length; j++) {
|
||||
System.out.print(" " + symbols[board[i][j]] + " |");
|
||||
}
|
||||
System.out.println("\n--------------------------------------------");
|
||||
}
|
||||
}
|
||||
|
||||
// Places water around a sunk ship to mark its surrounding area.
|
||||
private static void placeWaterAroundShip(int x, int y) {
|
||||
for (int i = y - 1; i <= y + 1; i++) {
|
||||
for (int j = x - 1; j <= x + 1; j++) {
|
||||
if (i >= 0 && i < 10 && j >= 0 && j < 10 && board[i][j] == BLANK) {
|
||||
board[i][j] = WATER;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Checks if all ships on the board are sunk.
|
||||
private static boolean allShipSunk() {
|
||||
for (int i = 0; i < board.length; i++) {
|
||||
for (int j = 0; j < board[i].length; j++) {
|
||||
if (board[i][j] == HIDDEN_SHIP || board[i][j] == REVEALED_SHIP) {
|
||||
return false; // Found a ship that is not sunk
|
||||
}
|
||||
}
|
||||
}
|
||||
return true; // All ships are sunk
|
||||
}
|
||||
}
|
BIN
Code/battleShip/src/test.class
Normal file
BIN
Code/battleShip/src/test.class
Normal file
Binary file not shown.
357
Code/battleShip/src/test.java
Normal file
357
Code/battleShip/src/test.java
Normal file
|
@ -0,0 +1,357 @@
|
|||
import java.util.Random;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class test {
|
||||
// Spielfeld-Zeichen
|
||||
public static final int LEER = 0; // ' '
|
||||
public static final int WASSER = 1; // 'O'
|
||||
public static final int SCHIFF = 2; // 'X'
|
||||
public static final int VERSENKT = 3; // 'S'
|
||||
public static final int VERSTECKT = 4; // ' '
|
||||
public static final int ENTHÜLLT = 5; // 'R'
|
||||
|
||||
// spielfeld[vertikal --> y][horizontal --> x]
|
||||
public static int[][] spielfeld = new int[10][10];
|
||||
|
||||
// Array, in dem die Schiffe gespeichert sind
|
||||
private static int[] schiffX = new int[10];
|
||||
private static int[] schiffY = new int[10];
|
||||
private static boolean[] schiffRichtung = new boolean[10];
|
||||
private static int[] schiffLänge = new int[10];
|
||||
|
||||
// Anzahl der abgefeuerten Schüsse
|
||||
public static int abgefeuerteSchüsse = 0;
|
||||
public static boolean spielLäuft = true;
|
||||
|
||||
public static void main(String[] args) {
|
||||
boolean sindSchiffeEnthüllt = false;
|
||||
// Regeln erklären
|
||||
spielInitialisieren();
|
||||
do {
|
||||
spielfeldZeigen();
|
||||
System.out.println(
|
||||
"Wohin möchtest du schießen? (z.B., A5 oder ? für einen Tipp oder -1 zum Beenden des Spiels)");
|
||||
String eingabe = koordinateEingeben();
|
||||
|
||||
switch (eingabe) {
|
||||
case "-1":
|
||||
spielLäuft = false;
|
||||
break;
|
||||
case "?":
|
||||
versteckteSchiffeZeigen();
|
||||
sindSchiffeEnthüllt = true;
|
||||
break;
|
||||
default:
|
||||
// Die Zeilen 47-49 sollten beim Debuggen deaktiviert werden, um es einfacher zu
|
||||
// machen
|
||||
if (sindSchiffeEnthüllt) {
|
||||
enthüllteSchiffeVerstecken();
|
||||
}
|
||||
schussVerarbeiten(eingabe);
|
||||
break;
|
||||
}
|
||||
} while (spielLäuft);
|
||||
}
|
||||
|
||||
// Verarbeitet die Schusseingabe des Spielers, validiert sie und führt den
|
||||
// Schuss aus.
|
||||
private static void schussVerarbeiten(String eingabe) {
|
||||
try {
|
||||
char xChar = eingabe.toLowerCase().charAt(0);
|
||||
int y = Integer.parseInt(eingabe.substring(1)) - 1;
|
||||
int x = xChar - 'a';
|
||||
if (eingabeIstGültig(x, y)) {
|
||||
String ergebnis = schießen(x, y);
|
||||
System.out.println(ergebnis);
|
||||
System.out.println("Anzahl der abgefeuerten Schüsse: " + abgefeuerteSchüsse);
|
||||
if (alleSchiffeVersenkt()) {
|
||||
spielfeldZeigen();
|
||||
System.out.println("Alle Schiffe wurden versenkt\nDu hast das Spiel gewonnen\n");
|
||||
spielfeldZeigen();
|
||||
spielLäuft = false;
|
||||
}
|
||||
} else {
|
||||
System.out.println("Ungültige Eingabe. Bitte gib eine gültige Koordinate ein (z.B., A5).");
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
System.out.println("Ungültiges Eingabeformat. Bitte gib eine gültige Koordinate ein (z.B., A5).");
|
||||
}
|
||||
}
|
||||
|
||||
// Zeigt die Positionen der versteckten Schiffe auf dem Spielfeld an.
|
||||
private static void versteckteSchiffeZeigen() {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
for (int j = 0; j < 10; j++) {
|
||||
if (spielfeld[i][j] == VERSTECKT) {
|
||||
spielfeld[i][j] = ENTHÜLLT;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Versteckt die zuvor enthüllten Schiffe auf dem Spielfeld.
|
||||
private static void enthüllteSchiffeVerstecken() {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
for (int j = 0; j < 10; j++) {
|
||||
if (spielfeld[i][j] == ENTHÜLLT) {
|
||||
spielfeld[i][j] = VERSTECKT;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Initialisiert das Spiel, indem das Spielfeld eingerichtet und Schiffe
|
||||
// zufällig platziert werden.
|
||||
private static void spielInitialisieren() {
|
||||
// Spielfeld mit leeren Feldern füllen
|
||||
for (int i = 0; i < spielfeld.length; i++) {
|
||||
for (int j = 0; j < spielfeld[i].length; j++) {
|
||||
spielfeld[i][j] = LEER;
|
||||
}
|
||||
}
|
||||
|
||||
// Schiffe zufällig platzieren
|
||||
Random zufall = new Random();
|
||||
int i = 0;
|
||||
int[] schiffe = { 4, 3, 3, 2, 2, 2, 1, 1, 1, 1 };
|
||||
for (int schiffGröße : schiffe) {
|
||||
boolean platziert = false;
|
||||
while (!platziert) {
|
||||
int x = zufall.nextInt(10);
|
||||
int y = zufall.nextInt(10);
|
||||
boolean richtung = zufall.nextBoolean();
|
||||
if (platzierungIstGültig(x, y, schiffGröße, richtung)) {
|
||||
schiffLänge[i] = schiffGröße;
|
||||
schiffX[i] = x;
|
||||
schiffY[i] = y;
|
||||
schiffRichtung[i] = richtung;
|
||||
|
||||
i++;
|
||||
schiffPlatzieren(x, y, schiffGröße, richtung);
|
||||
platziert = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Validiert die Platzierung eines Schiffs auf dem Spielfeld.
|
||||
private static boolean platzierungIstGültig(int x, int y, int schiffGröße, boolean richtung) {
|
||||
if (!innerhalbGrenzen(x, y, schiffGröße, richtung)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (überschneidung(x, y, schiffGröße, richtung)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return hatWasserPlatz(x, y, schiffGröße, richtung);
|
||||
}
|
||||
|
||||
// Überprüft, ob die Schiffplatzierung innerhalb der Spielfeldgrenzen liegt.
|
||||
private static boolean innerhalbGrenzen(int x, int y, int schiffGröße, boolean richtung) {
|
||||
if (richtung) {
|
||||
return x >= 0 && x + schiffGröße <= 10 && y >= 0 && y < 10;
|
||||
} else {
|
||||
return y >= 0 && y + schiffGröße <= 10 && x >= 0 && x < 10;
|
||||
}
|
||||
}
|
||||
|
||||
// Überprüft, ob sich die Schiffplatzierung mit vorhandenen Schiffen
|
||||
// überschneidet.
|
||||
private static boolean überschneidung(int x, int y, int schiffGröße, boolean richtung) {
|
||||
for (int i = 0; i < schiffGröße; i++) {
|
||||
int reihe = richtung ? y : y + i;
|
||||
int spalte = richtung ? x + i : x;
|
||||
|
||||
if (spielfeld[reihe][spalte] != LEER) {
|
||||
return true; // Überschneidet sich mit einem vorhandenen Schiff
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Stellt sicher, dass das Schiff einen Platz mit Wasser um sich herum hat.
|
||||
private static boolean hatWasserPlatz(int x, int y, int schiffGröße, boolean richtung) {
|
||||
for (int i = 0; i < schiffGröße; i++) {
|
||||
int reihe = richtung ? y : y + i;
|
||||
int spalte = richtung ? x + i : x;
|
||||
|
||||
for (int j = reihe - 1; j <= reihe + 1; j++) {
|
||||
for (int k = spalte - 1; k <= spalte + 1; k++) {
|
||||
if (j >= 0 && j < 10 && k >= 0 && k < 10 && spielfeld[j][k] != LEER) {
|
||||
return false; // Benachbartes Feld ist kein Wasser
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true; // Hat Platz mit Wasser
|
||||
}
|
||||
|
||||
// Platziert ein Schiff auf dem Spielfeld an den angegebenen Koordinaten.
|
||||
private static void schiffPlatzieren(int x, int y, int schiffGröße, boolean richtung) {
|
||||
if (richtung) {
|
||||
for (int i = 0; i < schiffGröße; i++) {
|
||||
spielfeld[y][x + i] = VERSTECKT;
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < schiffGröße; i++) {
|
||||
spielfeld[y + i][x] = VERSTECKT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Holt die Koordinateneingabe vom Benutzer.
|
||||
private static String koordinateEingeben() {
|
||||
Scanner scan = new Scanner(System.in);
|
||||
return scan.next();
|
||||
}
|
||||
|
||||
// Überprüft, ob die Eingabekoordinaten gültig sind.
|
||||
private static boolean eingabeIstGültig(int x, int y) {
|
||||
return x >= 0 && x < 10 && y >= 0 && y < 10;
|
||||
}
|
||||
|
||||
// Verarbeitet einen Schuss auf die angegebenen Koordinaten und gibt das
|
||||
// Ergebnis zurück.
|
||||
private static String schießen(int x, int y) {
|
||||
switch (spielfeld[y][x]) {
|
||||
case LEER:
|
||||
spielfeld[y][x] = WASSER;
|
||||
abgefeuerteSchüsse++;
|
||||
return "Daneben!";
|
||||
case WASSER:
|
||||
return "Dieses Feld wurde bereits beschossen!";
|
||||
case VERSTECKT:
|
||||
case ENTHÜLLT:
|
||||
spielfeld[y][x] = SCHIFF;
|
||||
abgefeuerteSchüsse++;
|
||||
if (schiffVersenkt(x, y)) {
|
||||
schiffVersenken(x, y);
|
||||
return "Du hast ein Schiff versenkt!";
|
||||
} else {
|
||||
return "Du hast ein Schiff getroffen!";
|
||||
}
|
||||
default:
|
||||
return "Ungültiger Zustand!";
|
||||
}
|
||||
}
|
||||
|
||||
// Versenkt ein Schiff, indem alle seine Teile als versenkt markiert werden.
|
||||
private static void schiffVersenken(int x, int y) {
|
||||
for (int i = 0; i < schiffX.length; i++) {
|
||||
int startX = schiffX[i];
|
||||
int startY = schiffY[i];
|
||||
int länge = schiffLänge[i];
|
||||
boolean richtung = schiffRichtung[i]; // true für horizontal, false für vertikal
|
||||
|
||||
// Überprüfen, ob der aktuelle Schuss Teil dieses Schiffes ist
|
||||
if (richtung) {
|
||||
// Horizontales Schiff
|
||||
if (y == startY && x >= startX && x < startX + länge) {
|
||||
// Markiere alle Teile des Schiffes als versenkt
|
||||
for (int j = 0; j < länge; j++) {
|
||||
spielfeld[startY][startX + j] = VERSENKT;
|
||||
}
|
||||
|
||||
for (int j = 0; j < länge; j++) {
|
||||
wasserUmSchiffPlatzieren(startX + j, startY);
|
||||
}
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// Vertikales Schiff
|
||||
if (x == startX && y >= startY && y < startY + länge) {
|
||||
// Markiere alle Teile des Schiffes als versenkt
|
||||
for (int j = 0; j < länge; j++) {
|
||||
spielfeld[startY + j][startX] = VERSENKT;
|
||||
}
|
||||
|
||||
for (int j = 0; j < länge; j++) {
|
||||
wasserUmSchiffPlatzieren(startX, startY + j);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Überprüft, ob ein Schiff an den angegebenen Koordinaten vollständig versenkt
|
||||
// ist.
|
||||
private static boolean schiffVersenkt(int x, int y) {
|
||||
for (int i = 0; i < schiffX.length; i++) {
|
||||
int startX = schiffX[i];
|
||||
int startY = schiffY[i];
|
||||
int länge = schiffLänge[i];
|
||||
boolean richtung = schiffRichtung[i]; // true für horizontal, false für vertikal
|
||||
|
||||
// Überprüfen, ob der aktuelle Schuss Teil dieses Schiffes ist
|
||||
if (richtung) {
|
||||
// Horizontales Schiff
|
||||
if (y == startY && x >= startX && x < startX + länge) {
|
||||
// Überprüfen alle Teile des Schiffes
|
||||
for (int j = 0; j < länge; j++) {
|
||||
if (spielfeld[startY][startX + j] != SCHIFF && spielfeld[startY][startX + j] != VERSENKT) {
|
||||
return false; // Wenn ein Teil nicht getroffen ist, ist das Schiff nicht versenkt
|
||||
}
|
||||
}
|
||||
return true; // Alle Teile sind getroffen, das Schiff ist versenkt
|
||||
}
|
||||
} else {
|
||||
// Vertikales Schiff
|
||||
if (x == startX && y >= startY && y < startY + länge) {
|
||||
// Überprüfen alle Teile des Schiffes
|
||||
for (int j = 0; j < länge; j++) {
|
||||
if (spielfeld[startY + j][startX] != SCHIFF && spielfeld[startY + j][startX] != VERSENKT) {
|
||||
return false; // Wenn ein Teil nicht getroffen ist, ist das Schiff nicht versenkt
|
||||
}
|
||||
}
|
||||
return true; // Alle Teile sind getroffen, das Schiff ist versenkt
|
||||
}
|
||||
}
|
||||
}
|
||||
return false; // Wenn der Schuss kein Teil eines Schiffes ist (sollte in einem gültigen Spiel
|
||||
// nicht passieren)
|
||||
}
|
||||
|
||||
// Zeigt den aktuellen Zustand des Spielfelds auf der Konsole an.
|
||||
private static void spielfeldZeigen() {
|
||||
System.out.println(" | A | B | C | D | E | F | G | H | I | J |");
|
||||
System.out.println("--------------------------------------------");
|
||||
char[] symbole = { ' ', 'O', 'X', 'S', ' ', 'R' };
|
||||
|
||||
for (int i = 0; i < spielfeld.length; i++) {
|
||||
if (i < 9) {
|
||||
System.out.print(" " + (i + 1) + " |");
|
||||
} else {
|
||||
System.out.print(" " + (i + 1) + "|");
|
||||
}
|
||||
for (int j = 0; j < spielfeld[i].length; j++) {
|
||||
System.out.print(" " + symbole[spielfeld[i][j]] + " |");
|
||||
}
|
||||
System.out.println("\n--------------------------------------------");
|
||||
}
|
||||
}
|
||||
|
||||
// Platziert Wasser um ein versenktes Schiff, um dessen Umgebung zu markieren.
|
||||
private static void wasserUmSchiffPlatzieren(int x, int y) {
|
||||
for (int i = y - 1; i <= y + 1; i++) {
|
||||
for (int j = x - 1; j <= x + 1; j++) {
|
||||
if (i >= 0 && i < 10 && j >= 0 && j < 10 && spielfeld[i][j] == LEER) {
|
||||
spielfeld[i][j] = WASSER;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Überprüft, ob alle Schiffe auf dem Spielfeld versenkt sind.
|
||||
private static boolean alleSchiffeVersenkt() {
|
||||
for (int i = 0; i < spielfeld.length; i++) {
|
||||
for (int j = 0; j < spielfeld[i].length; j++) {
|
||||
if (spielfeld[i][j] == VERSTECKT || spielfeld[i][j] == ENTHÜLLT) {
|
||||
return false; // Ein Schiff wurde gefunden, das nicht versenkt ist
|
||||
}
|
||||
}
|
||||
}
|
||||
return true; // Alle Schiffe sind versenkt
|
||||
}
|
||||
}
|
7
Code/bookAufgabe3/.vscode/settings.json
vendored
Normal file
7
Code/bookAufgabe3/.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/bookAufgabe3/README.md
Normal file
18
Code/bookAufgabe3/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/bookAufgabe3/bin/App.class
Normal file
BIN
Code/bookAufgabe3/bin/App.class
Normal file
Binary file not shown.
31
Code/bookAufgabe3/src/App.java
Normal file
31
Code/bookAufgabe3/src/App.java
Normal file
|
@ -0,0 +1,31 @@
|
|||
|
||||
// împort java extansions
|
||||
import java.util.Scanner;
|
||||
|
||||
public class App {
|
||||
public static void main(String[] args) {
|
||||
Scanner scan = new Scanner(System.in);
|
||||
|
||||
System.out.println("Give me a number please:");
|
||||
int number = scan.nextInt();
|
||||
int math = 0;
|
||||
int numberOfDigits = 0;
|
||||
int sum = 0;
|
||||
|
||||
// Number of digits
|
||||
for (int tempNumber = number; tempNumber > 0; tempNumber = tempNumber / 10) {
|
||||
numberOfDigits++;
|
||||
}
|
||||
|
||||
// math the digits-diffrence
|
||||
for (int tempNumber = number; tempNumber > 0; tempNumber = tempNumber / 10) {
|
||||
math = tempNumber % 10;
|
||||
sum += math;
|
||||
}
|
||||
|
||||
System.out.println("Anzahl der Ziffern: " + numberOfDigits);
|
||||
System.out.println("Ziffernsumme: " + sum);
|
||||
|
||||
scan.close();
|
||||
}
|
||||
}
|
7
Code/bookTaskTwo/.vscode/settings.json
vendored
Normal file
7
Code/bookTaskTwo/.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/bookTaskTwo/README.md
Normal file
18
Code/bookTaskTwo/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/bookTaskTwo/bin/App.class
Normal file
BIN
Code/bookTaskTwo/bin/App.class
Normal file
Binary file not shown.
16
Code/bookTaskTwo/src/App.java
Normal file
16
Code/bookTaskTwo/src/App.java
Normal file
|
@ -0,0 +1,16 @@
|
|||
import java.util.Scanner;
|
||||
|
||||
public class App {
|
||||
public static void main(String[] args) {
|
||||
Scanner scan = new Scanner(System.in);
|
||||
System.out.println("Please enter a postive number");
|
||||
int number = scan.nextInt();
|
||||
int numberDigits = 0;
|
||||
|
||||
for (int digits = 0; number > 0; digits++) {
|
||||
number = number / 10;
|
||||
numberDigits++;
|
||||
}
|
||||
System.out.println("Your number contains: " + numberDigits + " digit(s).");
|
||||
}
|
||||
}
|
7
Code/case/.vscode/settings.json
vendored
Normal file
7
Code/case/.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/case/README.md
Normal file
18
Code/case/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/case/bin/App.class
Normal file
BIN
Code/case/bin/App.class
Normal file
Binary file not shown.
41
Code/case/src/App.java
Normal file
41
Code/case/src/App.java
Normal file
|
@ -0,0 +1,41 @@
|
|||
import java.util.Scanner;
|
||||
|
||||
public class App {
|
||||
static Scanner scan = new Scanner(System.in);
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(
|
||||
"Arbeitstag-Nummer (1=Montag, 2=Dienstag, 3=Mittwoch, 4=Donnerstag, 5=Freitag)");
|
||||
int arbeitstagNummer = scan.nextInt();
|
||||
scan.close();
|
||||
String tag = "leer";
|
||||
|
||||
switch (arbeitstagNummer) {
|
||||
case 1:
|
||||
tag = "Montag";
|
||||
break;
|
||||
case 2:
|
||||
tag = "Dienstag";
|
||||
break;
|
||||
case 3:
|
||||
tag = "Mittwoch";
|
||||
break;
|
||||
case 4:
|
||||
tag = "Donnerstag";
|
||||
break;
|
||||
case 5:
|
||||
tag = "Freitag";
|
||||
break;
|
||||
|
||||
default:
|
||||
System.out.println("error");
|
||||
}
|
||||
|
||||
// Checking for errors
|
||||
if (tag.equals("leer")) {
|
||||
System.out.println("please don't do that again");
|
||||
} else {
|
||||
System.out.println(tag);
|
||||
}
|
||||
}
|
||||
}
|
7
Code/cute/.vscode/settings.json
vendored
Normal file
7
Code/cute/.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/cute/README.md
Normal file
18
Code/cute/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/cute/bin/App.class
Normal file
BIN
Code/cute/bin/App.class
Normal file
Binary file not shown.
6
Code/cute/src/App.java
Normal file
6
Code/cute/src/App.java
Normal file
|
@ -0,0 +1,6 @@
|
|||
public class App {
|
||||
public static void main(String[] args) throws Exception {
|
||||
System.out.println("Is Maria cuter than me?");
|
||||
System.out.println("yes ofc");
|
||||
}
|
||||
}
|
7
Code/debugging/.vscode/settings.json
vendored
Normal file
7
Code/debugging/.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/debugging/README.md
Normal file
18
Code/debugging/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/debugging/bin/App.class
Normal file
BIN
Code/debugging/bin/App.class
Normal file
Binary file not shown.
38
Code/debugging/src/App.java
Normal file
38
Code/debugging/src/App.java
Normal file
|
@ -0,0 +1,38 @@
|
|||
public class App {
|
||||
public static void main(String[] args) {
|
||||
double[] temperaturMesswerte = { 0.1, 4.3, 32.9, 329, 18.5, 123.4, 1.8, -7.3, 0.0, 3.7, -2.1, -455.8, 31.1,
|
||||
38.1 };
|
||||
double minPlausiblerWert = -60.0;
|
||||
double maxPlausiblerWert = 60.0;
|
||||
|
||||
System.out.println("Minimaler Wert: " + minValue(temperaturMesswerte, minPlausiblerWert, maxPlausiblerWert));
|
||||
double maximalerWert = maxValue(temperaturMesswerte, minPlausiblerWert, maxPlausiblerWert);
|
||||
System.out.println("Maximaler Wert: " + maximalerWert);
|
||||
}
|
||||
|
||||
/*
|
||||
* minValue
|
||||
*/
|
||||
public static double minValue(double[] messwerte, double minPlausibel, double maxPlausibel) {
|
||||
double minValue = Double.MAX_VALUE;
|
||||
for (int i = 0; i < messwerte.length; i++) {
|
||||
if (minValue > messwerte[i] && messwerte[i] >= minPlausibel && messwerte[i] <= maxPlausibel) {
|
||||
minValue = messwerte[i];
|
||||
}
|
||||
}
|
||||
return minValue;
|
||||
}
|
||||
|
||||
/*
|
||||
* maxValue
|
||||
*/
|
||||
public static double maxValue(double[] messwerte, double minPlausibel, double maxPlausibel) {
|
||||
double maxValue = Double.MIN_VALUE;
|
||||
for (int i = 0; i < messwerte.length; i++) {
|
||||
if (maxValue < messwerte[i] && messwerte[i] >= minPlausibel && messwerte[i] <= maxPlausibel) {
|
||||
maxValue = messwerte[i];
|
||||
}
|
||||
}
|
||||
return maxValue;
|
||||
}
|
||||
}
|
7
Code/debugging02/.vscode/settings.json
vendored
Normal file
7
Code/debugging02/.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/debugging02/README.md
Normal file
18
Code/debugging02/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/debugging02/bin/App.class
Normal file
BIN
Code/debugging02/bin/App.class
Normal file
Binary file not shown.
45
Code/debugging02/src/App.java
Normal file
45
Code/debugging02/src/App.java
Normal file
|
@ -0,0 +1,45 @@
|
|||
import java.util.Scanner;
|
||||
|
||||
public class App {
|
||||
|
||||
public static void main(String[] args) {
|
||||
Scanner scan = new Scanner(System.in);
|
||||
int[] varZahl = new int[10];
|
||||
|
||||
//Erfassen der Daten
|
||||
while (true) {
|
||||
System.out.println("Bitte eine Zahl zwischen 0 und 9 (99 zum beenden)");
|
||||
int gluecksZahl = scan.nextInt();
|
||||
if (gluecksZahl < 0 || gluecksZahl > 9) {
|
||||
break;
|
||||
}
|
||||
varZahl[gluecksZahl]++;
|
||||
}
|
||||
|
||||
//Ausgabe der Statistik
|
||||
for (int i = 0; i <= 9; i++) {
|
||||
System.out.println(i + " :" + varZahl[i]);
|
||||
}
|
||||
|
||||
//Ausgabe der maximal gewählten Zahl
|
||||
System.out.println("Meistgewählte Glückszahl: " + meistGewaehlteGlueckszahl(varZahl));
|
||||
|
||||
scan.close();
|
||||
}
|
||||
|
||||
/*
|
||||
* meistGewaehlteGlueckszahl
|
||||
*/
|
||||
public static int meistGewaehlteGlueckszahl(int[] gluecksZahlen) {
|
||||
int meistGewaehlteZahl = -1;
|
||||
int anzahlMax = Integer.MIN_VALUE;
|
||||
for (int i = 0; i < gluecksZahlen.length; i++) {
|
||||
if (anzahlMax < gluecksZahlen[i]) {
|
||||
anzahlMax = gluecksZahlen[i];
|
||||
meistGewaehlteZahl = i;
|
||||
}
|
||||
}
|
||||
|
||||
return meistGewaehlteZahl;
|
||||
}
|
||||
}
|
7
Code/dnd dice/.vscode/settings.json
vendored
Normal file
7
Code/dnd dice/.vscode/settings.json
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"java.project.sourcePaths": ["src"],
|
||||
"java.project.outputPath": "bin",
|
||||
"java.project.referencedLibraries": [
|
||||
"lib/**/*.jar"
|
||||
]
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue