|
| 1 | +# Methodendokumentation - Coordinates <!-- omit in toc --> |
| 2 | + |
| 3 | +## Inhaltsverzeichnis <!-- omit in toc --> |
| 4 | +- [Coordinates-Methoden](#coordinates-methoden) |
| 5 | + - [**getX()**](#getx) |
| 6 | + - [**getY()**](#gety) |
| 7 | + - [**getNeighbors()**](#getneighbors) |
| 8 | + - [**plus(Vector)**](#plusvector) |
| 9 | + - [**minus(Vector)**](#minusvector) |
| 10 | + - [**equals(Object)** (Coordinates)](#equalsobject-coordinates) |
| 11 | + |
| 12 | + |
| 13 | +## Coordinates-Methoden |
| 14 | +`Coordinates` repräsentiert zweidimensionale Koordinaten auf dem Spielfeld. |
| 15 | + |
| 16 | +--- |
| 17 | + |
| 18 | +### **getX()** |
| 19 | +Gibt den Wert der X-Koordinate zurück. |
| 20 | +- **Rückgabetyp:** `int` |
| 21 | + |
| 22 | +```java |
| 23 | +.getX() |
| 24 | +``` |
| 25 | + |
| 26 | +Das ganze Konstrukt: |
| 27 | + |
| 28 | +```java |
| 29 | +coordinates.getX() |
| 30 | +``` |
| 31 | + |
| 32 | +Hier ein Code-Beispiel: |
| 33 | + |
| 34 | +```java |
| 35 | +int x = coordinates.getX(); |
| 36 | +``` |
| 37 | + |
| 38 | +--- |
| 39 | + |
| 40 | +### **getY()** |
| 41 | +Gibt den Wert der Y-Koordinate zurück. |
| 42 | +- **Rückgabetyp:** `int` |
| 43 | + |
| 44 | +```java |
| 45 | +.getY() |
| 46 | +``` |
| 47 | + |
| 48 | +Das ganze Konstrukt: |
| 49 | + |
| 50 | +```java |
| 51 | +coordinates.getY() |
| 52 | +``` |
| 53 | + |
| 54 | +Hier ein Code-Beispiel: |
| 55 | + |
| 56 | +```java |
| 57 | +int y = coordinates.getY(); |
| 58 | +``` |
| 59 | + |
| 60 | +--- |
| 61 | + |
| 62 | +### **getNeighbors()** |
| 63 | +Gibt die Koordinaten aller Nachbarfelder zurück (in einer Collection). |
| 64 | +- **Rückgabetyp:** `Collection<Coordinates>` |
| 65 | + |
| 66 | +```java |
| 67 | +.getNeighbors() |
| 68 | +``` |
| 69 | + |
| 70 | +Das ganze Konstrukt: |
| 71 | + |
| 72 | +```java |
| 73 | +coordinates.getNeighbors() |
| 74 | +``` |
| 75 | + |
| 76 | +Hier ein Code-Beispiel: |
| 77 | + |
| 78 | +```java |
| 79 | +Collection<Coordinates> neighbors = coordinates.getNeighbors(); |
| 80 | +``` |
| 81 | + |
| 82 | +--- |
| 83 | + |
| 84 | +### **plus(Vector)** |
| 85 | +Addiert einen Vektor zu den Koordinaten und gibt das Ergebnis als neue Koordinaten zurück. |
| 86 | +- **Rückgabetyp:** `Coordinates` |
| 87 | + |
| 88 | +```java |
| 89 | +.plus(vector) |
| 90 | +``` |
| 91 | + |
| 92 | +Das ganze Konstrukt: |
| 93 | + |
| 94 | +```java |
| 95 | +coordinates.plus(vector) |
| 96 | +``` |
| 97 | + |
| 98 | +Hier ein Code-Beispiel: |
| 99 | + |
| 100 | +```java |
| 101 | +Coordinates newCoordinates = coordinates.plus(moveVector); |
| 102 | +``` |
| 103 | + |
| 104 | +--- |
| 105 | + |
| 106 | +### **minus(Vector)** |
| 107 | +Subtrahiert einen Vektor von den Koordinaten und gibt das Ergebnis als neue Koordinaten zurück. |
| 108 | +- **Rückgabetyp:** `Coordinates` |
| 109 | + |
| 110 | +```java |
| 111 | +.minus(vector) |
| 112 | +``` |
| 113 | + |
| 114 | +Das ganze Konstrukt: |
| 115 | + |
| 116 | +```java |
| 117 | +coordinates.minus(vector) |
| 118 | +``` |
| 119 | + |
| 120 | +Hier ein Code-Beispiel: |
| 121 | + |
| 122 | +```java |
| 123 | +Coordinates newCoordinates = coordinates.minus(moveVector); |
| 124 | +``` |
| 125 | + |
| 126 | +--- |
| 127 | + |
| 128 | +### **equals(Object)** (Coordinates) |
| 129 | +Vergleicht die Koordinaten mit einem anderen Objekt (normalerweise anderen Koordinaten). |
| 130 | +- **Rückgabetyp:** `boolean` |
| 131 | + |
| 132 | +```java |
| 133 | +.equals(object) |
| 134 | +``` |
| 135 | + |
| 136 | +Das ganze Konstrukt: |
| 137 | + |
| 138 | +```java |
| 139 | +coordinates.equals(otherCoordinates) |
| 140 | +``` |
| 141 | + |
| 142 | +Hier ein Code-Beispiel: |
| 143 | + |
| 144 | +```java |
| 145 | +boolean areEqual = coordinates.equals(new Coordinates(2, 3)); |
| 146 | +``` |
0 commit comments