Added list

This commit is contained in:
Paul H 2025-03-02 11:11:09 +01:00
parent 26c8e9b7e2
commit c9af65ef6d
20 changed files with 321 additions and 30 deletions

49
.idea/workspace.xml generated
View File

@ -5,22 +5,8 @@
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="395d95f7-d752-4ca0-b261-78679f611e7e" name="Changes" comment=""> <list default="true" id="395d95f7-d752-4ca0-b261-78679f611e7e" name="Changes" comment="">
<change afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/vcs.xml" beforeDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/encodings.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/uiDesigner.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/chess/example-output.txt" afterDir="false" />
<change afterPath="$PROJECT_DIR$/chess/pom.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/chess/src/main/java/de/vivi/chess/Main.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/chess/src/main/java/de/vivi/chess/board/Board.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/chess/src/main/java/de/vivi/chess/board/Field.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/chess/src/main/java/de/vivi/chess/game/Game.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/chess/src/main/java/de/vivi/chess/pieces/Color.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/chess/src/main/java/de/vivi/chess/pieces/Piece.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/chess/src/main/java/de/vivi/chess/pieces/Type.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/chess/todo.txt" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -38,27 +24,30 @@
<component name="Git.Settings"> <component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" /> <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component> </component>
<component name="ProjectColorInfo">{
&quot;associatedIndex&quot;: 4
}</component>
<component name="ProjectId" id="2t4pEbnSWeDCfbjBDdHvVwWVJbu" /> <component name="ProjectId" id="2t4pEbnSWeDCfbjBDdHvVwWVJbu" />
<component name="ProjectLevelVcsManager" settingsEditedManually="true" /> <component name="ProjectLevelVcsManager" settingsEditedManually="true" />
<component name="ProjectViewState"> <component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" /> <option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" /> <option name="showLibraryContents" value="true" />
</component> </component>
<component name="PropertiesComponent"><![CDATA[{ <component name="PropertiesComponent">{
"keyToString": { &quot;keyToString&quot;: {
"Application.Main.executor": "Run", &quot;Application.Main.executor&quot;: &quot;Run&quot;,
"Application.Unnamed.executor": "Run", &quot;Application.Unnamed.executor&quot;: &quot;Run&quot;,
"RunOnceActivity.OpenProjectViewOnStart": "true", &quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;,
"RunOnceActivity.ShowReadmeOnStart": "true", &quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
"SHARE_PROJECT_CONFIGURATION_FILES": "true", &quot;SHARE_PROJECT_CONFIGURATION_FILES&quot;: &quot;true&quot;,
"git-widget-placeholder": "main", &quot;git-widget-placeholder&quot;: &quot;master&quot;,
"jdk.selected.JAVA_MODULE": "temurin-17", &quot;jdk.selected.JAVA_MODULE&quot;: &quot;temurin-17&quot;,
"kotlin-language-version-configured": "true", &quot;kotlin-language-version-configured&quot;: &quot;true&quot;,
"project.structure.last.edited": "Modules", &quot;project.structure.last.edited&quot;: &quot;Modules&quot;,
"project.structure.proportion": "0.0", &quot;project.structure.proportion&quot;: &quot;0.0&quot;,
"project.structure.side.proportion": "0.0" &quot;project.structure.side.proportion&quot;: &quot;0.0&quot;
} }
}]]></component> }</component>
<component name="RunManager"> <component name="RunManager">
<configuration name="Unnamed" type="Application" factoryName="Application" nameIsGenerated="true"> <configuration name="Unnamed" type="Application" factoryName="Application" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="de.vivi.chess.Main" /> <option name="MAIN_CLASS_NAME" value="de.vivi.chess.Main" />

3
list/.idea/.gitignore generated vendored Normal file
View File

@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

13
list/.idea/compiler.xml generated Normal file
View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<annotationProcessing>
<profile name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="list" />
</profile>
</annotationProcessing>
</component>
</project>

7
list/.idea/encodings.xml generated Normal file
View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
</component>
</project>

20
list/.idea/jarRepositories.xml generated Normal file
View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Central Repository" />
<option name="url" value="https://repo.maven.apache.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
</component>
</project>

14
list/.idea/misc.xml generated Normal file
View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="temurin-17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

View File

17
list/pom.xml Normal file
View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>list</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>

View File

@ -0,0 +1,73 @@
package de.vivi.list;
public class Main {
public static void main(String[] args) {
ByteList array = new ArrayByteList();
ByteList linked = new LinkedByteList();
ByteList combined = new CombinedByteList(16);
testList(array);
testList(linked);
testList(combined);
testSort(array);
testSort(linked);
testSort(combined);
}
private static void testList(ByteList list) {
// add the element at the end
list.add((byte) 10);
list.add((byte) 5);
list.add((byte) -86);
list.add((byte) 3);
// add the element at the specified index
list.add(3, (byte) 99);
list.add(2, (byte) -40);
// remove the element at the specified index
list.remove(2);
list.remove(3);
// set the element at the specified index
list.set(1, 43);
list.set(0, 8);
// get the element at the specified index
list.get(2);
list.get(1);
// get the size
list.size();
// does the list contain the specified element?
list.contains(43);
// remove all elements inside the list
list.clear();
// return a copy of the list
list.copy();
// return a string of the form: [1, 84, 53]
list.toString();
// allow to use for each loop on list
for (byte value : list) {
// do some stuff with value...
}
}
private static void testSort(ByteList list) {
ByteSort bubble = new BubbleSort();
ByteSort merge = new MergeSort();
ByteSort bogo = new BogoSort();
// sort the lists with the sorting algorithm
bubble.sort(list.copy());
merge.sort(list.copy());
bogo.sort(list.copy());
}
}

3
minesweeper/.idea/.gitignore generated vendored Normal file
View File

@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

13
minesweeper/.idea/compiler.xml generated Normal file
View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<annotationProcessing>
<profile name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="minesweeper" />
</profile>
</annotationProcessing>
</component>
</project>

7
minesweeper/.idea/encodings.xml generated Normal file
View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
</component>
</project>

20
minesweeper/.idea/jarRepositories.xml generated Normal file
View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Central Repository" />
<option name="url" value="https://repo.maven.apache.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
</component>
</project>

14
minesweeper/.idea/misc.xml generated Normal file
View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="temurin-17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

6
minesweeper/.idea/vcs.xml generated Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

17
minesweeper/pom.xml Normal file
View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>minesweeper</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>

View File

@ -0,0 +1,40 @@
package de.vivi.minesweeper;
public class Main {
private static final int DEFAULT_SIZE = 8;
public static void main(String[] args) {
int size;
Mode mode;
if (args.length != 2) {
System.out.println("Usage: minesweeper [size] [mode]");
return;
}
try {
size = Integer.parseInt(args[0]);
} catch (NumberFormatException e) {
size = -1;
}
if (size < DEFAULT_SIZE) {
System.out.println("Invalid size provided, must be number greater or equal " + DEFAULT_SIZE);
}
switch (args[1]) {
case "easy": mode = new EasyMode(); break;
case "normal": mode = new NormalMode(); break;
case "hard": mode = new HardMode(); break;
default:
System.out.println("Invalid mode provided, must be easy, normal or hard");
return;
}
Board board = new Board(size);
Game game = new Game(mode, board);
game.start();
}
}

View File

@ -0,0 +1,15 @@
package de.vivi.minesweeper.board;
/**
* TODO:
*
* This class is the board. The board should have a constructor
* that takes the size as a parameter. It is a 2D grid. This should
* be implemented similar to the chess game, this includes printing
* to the console. But instead of rendering it with pawns and white
* and black squares, it should be rendered with a '#' for an
* unrevealed tile, a ' ' for a revealed tile and with a number,
* if it has unrevealed neighbors containing a mine.
*/
public class Board {
}

View File

@ -0,0 +1,11 @@
package de.vivi.minesweeper.game;
/**
* TODO:
*
* This class is the game. It should contain a constructor that
* takes as a parameter the mode and the board. It also should
* contain a start method for starting the game.
*/
public class Game {
}

View File

@ -0,0 +1,9 @@
package de.vivi.minesweeper.mode;
/**
* TODO:
*
*
*/
public interface Mode {
}