diff --git a/Programmierung2/src/Algorithmus/Allgemeine_Übungen.java b/Programmierung2/src/Algorithmus/Allgemeine_Übungen.java index 89f0a17..c46d699 100644 --- a/Programmierung2/src/Algorithmus/Allgemeine_Übungen.java +++ b/Programmierung2/src/Algorithmus/Allgemeine_Übungen.java @@ -3,36 +3,37 @@ package Algorithmus; public class Allgemeine_Übungen { public static void main(String[] args) { - String text = "HalloWelt"; - String o = "o"; - text.substring(0, 0); - int x = indexof(text,o); - System.out.println(x); - } - - public static int indexof(String text,String s) { - for (int i = 0; i < text.length(); i++) - if (text.charAt(i) == s.charAt(0)) - return i; - return 0; - } - - - - public static void find_Sub_Array(int[] arr, int target) { - - int merker = 0; - for (int i = 0; i < arr.length -1 ; i++) { - merker = arr[i]; - for (int j = i + 1; j < arr.length; j++) { - merker += arr[j]; - if (merker == target) { - System.out.println("Ab Index: " + i + " bis Index: " + j + " sind die Summer der Zahl: " + target); - break; - } - } + String text = "H"; + try { + System.out.println(codePointBefore(text,1)); + + }catch(StringIndexOutOfBoundsException e) { + System.out.println(e.toString()); } + + } + + static int codePointBefore(String s, int index)throws StringIndexOutOfBoundsException{ + if (index > s.length() + 1 || index < 1) + throw new StringIndexOutOfBoundsException(); + + char[] charArray = s.toCharArray(); + return charArray[index-1]; + } + + static int codePointAt(String s, int index)throws StringIndexOutOfBoundsException { + if (index > s.length() || index < 0) + throw new StringIndexOutOfBoundsException(); + char[] charArray = s.toCharArray(); + return charArray[index]; + } + + static char charAt(String s, int index) throws StringIndexOutOfBoundsException { + if (index > s.length() || index < 0) + throw new StringIndexOutOfBoundsException(); + char[] charArray = s.toCharArray(); + return charArray[index]; } } diff --git a/Programmierung2/src/Git/Branche erstellen.pdf b/Programmierung2/src/Git/Branche erstellen.pdf new file mode 100644 index 0000000..643c323 Binary files /dev/null and b/Programmierung2/src/Git/Branche erstellen.pdf differ diff --git a/Programmierung2/src/Git/HEAD & Master.pdf b/Programmierung2/src/Git/HEAD & Master.pdf new file mode 100644 index 0000000..7effb61 Binary files /dev/null and b/Programmierung2/src/Git/HEAD & Master.pdf differ diff --git a/Programmierung2/src/Übungen/Ponggame/GamePlay.java b/Programmierung2/src/Übungen/Ponggame/GamePlay.java index 8da4bf6..fd56467 100644 --- a/Programmierung2/src/Übungen/Ponggame/GamePlay.java +++ b/Programmierung2/src/Übungen/Ponggame/GamePlay.java @@ -5,7 +5,7 @@ import java.util.Random; public class GamePlay { public static void main(String[] args) { - GameWindow game = new GameWindow(); + new GameWindow(); }