Created
November 16, 2010 11:54
-
-
Save nicolaracco/701731 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Carta { | |
private static enum Seme { Oro, Bastoni, Coppe, Spade } | |
private int value; | |
private Seme seme; | |
public Carta(int value, Seme seme) { this.value = value; this.seme = seme; } | |
public int getValue() { return int; } | |
public Seme getSeme() { return seme; } | |
} | |
class InsiemeCarte extends LinkedList<Carta> { | |
public int quantiOri() { | |
int count = 0; | |
foreach (Carta c in this) | |
if (c.getSeme() == Carta.Seme.Oro) | |
count++; | |
return count; | |
} | |
} | |
class Mazzo extends ArrayList<Carta> { | |
public Carta lowestCard() { | |
Carta lowest = null; | |
foreach (Carta c in this) | |
if (lowest == null || c.getValue() < lowest.getValue()) | |
lowest = c; | |
return lowest; | |
} | |
} | |
class Tavolo extends ArrayList<Carta> { | |
private Tavolo() { } | |
private static Tavolo _instance; | |
public static Tavolo instance() { return _instance != null ? _instance : _instance = new Tavolo(); } | |
public LinkedList<InsiemeCarte> bestCardsThatMatches(int match) { | |
// metodo | |
} | |
} | |
class Giocatore { | |
private Mazzo mazzo; | |
public int turno() { | |
InsiemeCarte migliore = null; | |
foreach (Carta c in mieCarte) { | |
migliori = Tavolo.instance().bestCardsThatMatches(c.getValue()); | |
foreach (InsiemeCarte migliori_i in migliori) | |
if (migliori_i.count() > migliore.count()) | |
migliore = migliori_i; | |
} | |
if (migliore == null) | |
return mazzo.lowestCard(); | |
else | |
return migliore; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment