I have to prepare some work until tomorrow, but I'm stuck. (Also all the names in the code are German, don't be confused :) )
This is my constructor class for an object called "Karte"
(card)
private Farbe f;
private Wert w;
public enum Farbe {
PIK, KREUZ, KARO, HERZ
}
public enum Wert {
SIEBEN, ACHT, NEUN, ZEHN, BUBE, DAME, KOENIG, ASS
}
Karte(Farbe f, Wert w) {
this.f = f;
this.w = w;
}
public Farbe getFarbe() {
return f;
}
public Wert getWert() {
return w;
}
public String toString() {
return f + " " + w;
}
And now there's another class
that should generate an object
, made out of multiple cards.
The normal syntax would be
Karte name = new Karte(); // (random stuff here);
But how can I get the class to generate multiple objects with random names? If I tried to just use this kind of code in a for each
loop it would just overwrite the previous one.
How do I give them random names or even chosen from a String[]
?