forked from IF-LK-2020/arrays2
Compare commits
5 Commits
444859323c
...
fee447429b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fee447429b | ||
|
|
ce8b11f4dc | ||
|
|
fe1dca6d7a | ||
|
|
e96ae83b7e | ||
|
|
f66878689e |
45
Arrays.java
45
Arrays.java
@@ -51,7 +51,11 @@ public class Arrays {
|
|||||||
* @see Wuerfel#werfen()
|
* @see Wuerfel#werfen()
|
||||||
*/
|
*/
|
||||||
public void rollAll( Wuerfel[] pArray ) {
|
public void rollAll( Wuerfel[] pArray ) {
|
||||||
// TODO: implementieren
|
for (Wuerfel w : pArray) {
|
||||||
|
if (w != null) {
|
||||||
|
w.werfen();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -64,8 +68,13 @@ public class Arrays {
|
|||||||
* @see Wuerfel#getAugenzahl()
|
* @see Wuerfel#getAugenzahl()
|
||||||
*/
|
*/
|
||||||
public int diceSum( Wuerfel[] pArray ) {
|
public int diceSum( Wuerfel[] pArray ) {
|
||||||
// TODO: implementieren
|
int sum = 0;
|
||||||
return 0;
|
for (Wuerfel w : pArray) {
|
||||||
|
if (w != null) {
|
||||||
|
sum += w.getAugenzahl();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -77,7 +86,13 @@ public class Arrays {
|
|||||||
* @see Wuerfel#werfen()
|
* @see Wuerfel#werfen()
|
||||||
*/
|
*/
|
||||||
public void twoDimRoll( Wuerfel[][] pArray ) {
|
public void twoDimRoll( Wuerfel[][] pArray ) {
|
||||||
// TODO: implementieren
|
for (int i = 0; i < pArray.length; i++) {
|
||||||
|
for (Wuerfel w : pArray[i]) {
|
||||||
|
if (w != null) {
|
||||||
|
w.werfen();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -90,8 +105,15 @@ public class Arrays {
|
|||||||
* @see Wuerfel#getAugenzahl()
|
* @see Wuerfel#getAugenzahl()
|
||||||
*/
|
*/
|
||||||
public int twoDimSum( Wuerfel[][] pArray ) {
|
public int twoDimSum( Wuerfel[][] pArray ) {
|
||||||
// TODO: implementieren
|
int sum = 0;
|
||||||
return 0;
|
for (int i = 0; i < pArray.length; i++) {
|
||||||
|
for (Wuerfel w : pArray[i]) {
|
||||||
|
if (w != null) {
|
||||||
|
sum += w.getAugenzahl();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -104,8 +126,15 @@ public class Arrays {
|
|||||||
* @return Ein eindimensionales Array mit den Zeilensummen
|
* @return Ein eindimensionales Array mit den Zeilensummen
|
||||||
*/
|
*/
|
||||||
public int[] rowSum( Wuerfel[][] pArray ) {
|
public int[] rowSum( Wuerfel[][] pArray ) {
|
||||||
// TODO: implementieren
|
int[] rowSum = new int[pArray.length];
|
||||||
return null;
|
for (int i = 0; i < pArray.length; i++) {
|
||||||
|
for (Wuerfel w : pArray[i]) {
|
||||||
|
if (w != null) {
|
||||||
|
rowSum[i] += w.getAugenzahl();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return rowSum;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user