first commit

This commit is contained in:
2025-11-26 13:56:55 +01:00
commit c5f25901e1
188 changed files with 52799 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

8
Hjemmeopgaver/Hjemmeopgave nr. 2/.idea/.gitignore generated vendored Normal file
View File

@@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

View File

@@ -0,0 +1,9 @@
<component name="libraryTable">
<library name="Gruppeaflevering 2 - Gruppe 13 - kode">
<CLASSES>
<root url="jar://$PROJECT_DIR$/Gruppeaflevering 2 - Gruppe 13 - kode.zip!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="KubernetesApiProvider"><![CDATA[{}]]></component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="21" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/Hjemmeopgave nr. 2.iml" filepath="$PROJECT_DIR$/Hjemmeopgave nr. 2.iml" />
</modules>
</component>
</project>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@@ -0,0 +1,37 @@
import java.util.Random;
import java.util.Scanner;
public class RandomWalk {
public static void main(String[] args) {
Scanner console = new Scanner(System.in);
Random random = new Random();
System.out.print("Enter size of grid: ");
int gridSize = 0;
if (!console.hasNextInt()) {
throw new IllegalArgumentException("Not a number");
} else {
gridSize = Math.abs(console.nextInt());
}
StdDraw.setXscale(-gridSize, gridSize); // Opsætning af StdDraw, sætter størelse på felt til -gridSize, gridSize i x og y.
StdDraw.setYscale(-gridSize, gridSize);
StdDraw.setPenRadius(2.0 / (gridSize*4));
int x = 0;
int y = 0;
int numSteps = 0;
while (
x >= -gridSize && x <= gridSize && y >= -gridSize && y <= gridSize // Mens punktet er inde for -gridSize, gridSize i både x og y.
) {
int direction = random.nextInt(4); // Random værdi (0, 1, 2 eller 3). 0 = op. 1 = ned. 2 = venstre. 3 = højre.
if (direction >= 2) {
x += (direction == 3 ? 1 : -1); // Bevæg sig venstre eller højre
} else {
y += (direction == 1 ? 1 : -1); // Bevæg sig op eller ned
}
System.out.println("Position: (" + x + ", " + y + ")");
numSteps++;
StdDraw.point(x,y);
}
System.out.println("Total number of steps: " + numSteps);
}
}

File diff suppressed because it is too large Load Diff