It looks like you're new here. If you want to get involved, click one of these buttons!
.
points display
^
|
|
card table <-- state --> chart A
|
|
v
chart B
class PointsDisplay {
attribute GameState gameState;
method testForUpdate() {
every second do {
if(gameState.hasStateChanged()){
displayPoints(gameState.getPoints());
}
}
}
}class AI {
method nextMove(){
Card card = takeCard();
updateChartA(card);
updateChartB(card);
updateCardTable(card);
updatePointsDisplay(card);
}
}
class CardTable { //This is the gui that shows data, but also
//retrieves input of the human player
method playersHasChosenCard(Card card){
updateChartA(card);
updateChartB(card);
updateCardTable(card);
updatePointsDisplay(card);
}
}class GameState {
attribute ChartA chartA;
attribute ChartB chartB;
attribute PointsDisplay points;
attribute CardTable table;
method update(){
chartA.update(updateInfo);
chartB.update(updateInfo);
points.update(updateInfo);
table.update(updateInfo);
}
}class GameState {
attribute ChartA chartA;
attribute ChartB chartB;
attribute PointsDisplay points;
attribute CardTable table;
method update(){
if(chartA.isAvailable()) {
chartA.update(updateInfo);
}
if(chartB.isAvailable()) {
chartB.update(updateInfo);
}
points.update(updateInfo);
table.update(updateInfo);
}
}class GameState {
attribute ObserverCollection observers;
method notify(){
foreach Observer o in observers {
o.update();
}
}
}class PointsDisplay extends Observer {
attribute GameState gameState;
method update() {
State state = gameState.getState();
displayPoints(state.getPoints());
}
}