|
|
||
|---|---|---|
| src/de/hs_mannheim/MeineArrayList | ||
| .classpath | ||
| .gitignore | ||
| .project | ||
| LICENSE | ||
| README.md | ||
README.md
PR1_Aufgabensammlung_Erstelle_Arraylist
In diesem Repo finden Sie die Aufgabenstellung mit Tests. Sie müssen lediglich die Klasse MeineArrayList fertig implementieren. Mit Hilfe der Tests wissen Sie, ob die Aufgabe korrekt ist.
Aufgabe
Implementieren Sie die Klasse MeineArrayList so, dass sie die Grundlegenden Funktionen einer ArrayList<String> hat ohne ArrayList<> in der Klasse zu verwenden.
Zu implementierende Methoden
Die folgenden Methoden sind in der Klasse zu implementieren. Die Methoden und ihre Beschreibung sind der offiziellen Java documentation zu entnehmen. https://docs.oracle.com/javase/8/docs/api/java/util/ArrayList.html
Achtung! Die Methoden müssen für die Aufgabe ein wenig angepasst werden.
| Methode | Parameter | Rückgabetyp | Rückgabewert |
|---|---|---|---|
| add(String n) | n: String to be appended | void | |
| add(int index, String n) | index: index at which the specified String is to be inserted n: String to be inserted |
Boolean | true: erfolgreich false: fehlgeschlagen (out of bounds) |
| addAll(MeineArrayList liste) | liste: list wich gets appended | void | |
| addAll(int index, MeineArrayList liste) | index: index at which to insert the first element list: list containing Strings to be added to this list |
Boolean | true: erfolgreich false: fehlgeschlagen (out of bounds) |
| clear() | void | ||
| contains(String s) | s: String to search | Boolean | true: the same String exists (s.eaquals()) in the list false: the String doesn't exists in the list. |
| get(int index) | index: index to return | String | returns the String from the specifed index retruns an empty String if index is out of bounds |
| indexOf(String s) | s: String to search | int | Returns the index of the first eaqual String in this list, or -1 if this list does not contain the element. |
| isEmpty() | Boolean | Returns true if the list contains no elements. | |
| remove(int index) | index: index to remove | String | removes the specified index and returns the removed String. returns empty String if the index is out of bounds and doesn't remove anything |
| set(int index, String s) | index: index to replace s: String to replace with. |
Boolean | Replaces the String at the specified position in this list with the specified String. returns false if index is out of bounds and does nothing else true |
| size() | int | Returns the number of elements in this list. | |
| toArray() | String[] | Returns an array containing all Strings in this list in proper sequence (from first to last String). The returned Array is a deep copy. This means that if you change a String in the returned Array the String isn't changed in this list |