add Java Project #2

Merged
lgc merged 6 commits from ole into main 2024-10-29 11:49:50 +00:00
16 changed files with 305 additions and 0 deletions

29
.gitignore vendored Normal file
View File

@ -0,0 +1,29 @@
### IntelliJ IDEA ###
out/
!**/src/main/**/out/
!**/src/test/**/out/
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store

3
.idea/.gitignore vendored Normal file
View File

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

View File

@ -0,0 +1,9 @@
<component name="libraryTable">
<library name="jlayer-1.0.3">
<CLASSES>
<root url="jar://$USER_HOME$/Downloads/jlayer-master/jlayer-master/target/jlayer-1.0.3.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

5
.idea/misc.xml Normal file
View File

@ -0,0 +1,5 @@
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="liberica-full-23" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

8
.idea/modules.xml Normal file
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$/SchiffeVersenken.iml" filepath="$PROJECT_DIR$/SchiffeVersenken.iml" />
</modules>
</component>
</project>

7
.idea/vcs.xml Normal file
View File

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

12
SchiffeVersenken.iml Normal file
View File

@ -0,0 +1,12 @@
<?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$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="jlayer-1.0.3" level="project" />
</component>
</module>

View File

@ -0,0 +1,134 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AutoImportSettings">
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="91d861bd-39f2-4f7d-9002-31d86c6d3b79" name="Changes" comment="" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Record" />
<option value="Enum" />
<option value="Class" />
</list>
</option>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/.." />
</component>
<component name="ProjectColorInfo">{
&quot;customColor&quot;: &quot;&quot;,
&quot;associatedIndex&quot;: -1
}</component>
<component name="ProjectId" id="2o43faNdzvB3omBPjZ0MFw1dSOh" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"Downloaded.Files.Path.Enabled": "false",
"Repository.Attach.Annotations": "false",
"Repository.Attach.JavaDocs": "false",
"Repository.Attach.Sources": "false",
"RunOnceActivity.OpenProjectViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"SHARE_PROJECT_CONFIGURATION_FILES": "true",
"git-widget-placeholder": "ole",
"last_opened_file_path": "C:/Users/OleWachtel/Desktop/Uni/WeSe2425/programmieren-projekt",
"project.structure.last.edited": "Libraries",
"project.structure.proportion": "0.0",
"project.structure.side.proportion": "0.2",
"settings.editor.selected.configurable": "preferences.lookFeel"
},
"keyToStringList": {
"GitStage.ChangesTree.GroupingKeys": [
"directory",
"module",
"repository"
]
}
}]]></component>
<component name="RunManager">
<configuration name="HalloSchiffeVersenken" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="HalloSchiffeVersenken" />
<module name="SchiffeVersenken" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<recent_temporary>
<list>
<item itemvalue="Application.HalloSchiffeVersenken" />
</list>
</recent_temporary>
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="91d861bd-39f2-4f7d-9002-31d86c6d3b79" name="Changes" comment="" />
<created>1730115126753</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1730115126753</updated>
</task>
<task id="LOCAL-00001" summary="add Java Project">
<option name="closed" value="true" />
<created>1730115284405</created>
<option name="number" value="00001" />
<option name="presentableId" value="LOCAL-00001" />
<option name="project" value="LOCAL" />
<updated>1730115284405</updated>
</task>
<task id="LOCAL-00002" summary="add SoundHandler to Play sounds and Mute global">
<option name="closed" value="true" />
<created>1730129036486</created>
<option name="number" value="00002" />
<option name="presentableId" value="LOCAL-00002" />
<option name="project" value="LOCAL" />
<updated>1730129036486</updated>
</task>
<task id="LOCAL-00003" summary="delete Sounds.java">
<option name="closed" value="true" />
<created>1730129210987</created>
<option name="number" value="00003" />
<option name="presentableId" value="LOCAL-00003" />
<option name="project" value="LOCAL" />
<updated>1730129210987</updated>
</task>
<task id="LOCAL-00004" summary="add classes blank">
<option name="closed" value="true" />
<created>1730201990808</created>
<option name="number" value="00004" />
<option name="presentableId" value="LOCAL-00004" />
<option name="project" value="LOCAL" />
<updated>1730201990808</updated>
</task>
<option name="localTasksCounter" value="5" />
<servers />
</component>
<component name="Vcs.Log.Tabs.Properties">
<option name="TAB_STATES">
<map>
<entry key="MAIN">
<value>
<State />
</value>
</entry>
</map>
</option>
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="add Java Project" />
<MESSAGE value="add SoundHandler to Play sounds and Mute global" />
<MESSAGE value="delete Sounds.java" />
<MESSAGE value="add classes blank" />
<option name="LAST_COMMIT_MESSAGE" value="add classes blank" />
</component>
</project>

BIN
Sound/water-drip.mp3 Normal file

Binary file not shown.

2
src/Board.java Normal file
View File

@ -0,0 +1,2 @@
public class Board {
}

View File

@ -0,0 +1,19 @@
public class HalloSchiffeVersenken {
public static void main(String[] args) throws InterruptedException {
System.out.println("HelloSchiffeVersenekn");
System.out.println("sound");
SoundHandler.playSound("hit");
Thread.sleep(3000);
System.out.println("sound");
SoundHandler.playSound("hit");
SoundHandler.setSoundOn(false);
System.out.println("sound off");
SoundHandler.playSound("hit");
}
}

6
src/HitResponse.java Normal file
View File

@ -0,0 +1,6 @@
import java.awt.*;
public class HitResponse {
private HitResponseType type;
private Point point;
}

3
src/HitResponseType.java Normal file
View File

@ -0,0 +1,3 @@
public enum HitResponseType {
MISS, HIT, SUNK, VICTORY
}

5
src/OnlinePlayer.java Normal file
View File

@ -0,0 +1,5 @@
import java.net.Socket;
public abstract class OnlinePlayer extends Player{
private Socket socket;
}

26
src/Player.java Normal file
View File

@ -0,0 +1,26 @@
import java.awt.*;
public abstract class Player {
private boolean myTurn;
private boolean isServer;
private boolean waitingForResponse;
private Player enemy;
private String name;
private Board board;
public void receiveShoot(Point point) {
}
public void receiveHit(HitResponse hitResponse) {
}
public void click(Point point) {
}
public void beginTrun() {
}
}

37
src/SoundHandler.java Normal file
View File

@ -0,0 +1,37 @@
import javazoom.jl.decoder.JavaLayerException;
import javazoom.jl.player.Player;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
public class SoundHandler {
private static boolean soundOn = true;
private static HashMap<String, String> sounds = new HashMap<String, String>(Map.of(
"hit", "~/../Sound/water-drip.mp3"
));
public static void playSound(String soundName) {
if (soundOn) {
try {
Player player = new Player(new FileInputStream(sounds.get(soundName)));
player.play();
} catch (JavaLayerException | FileNotFoundException e) {
System.out.println("dslkfsfnsldfnlsnfsdnölscls");
e.printStackTrace();
}
}
}
static void add(String soundName, String path){
sounds.put(soundName, path);
}
static void setSoundOn(boolean sound){
soundOn= sound;
}
}