1. Actor :
package monopoly.actors;
public abstract class Actor
{
protected String name;
protected int kontoStand;
public Actor( String name, int kontoStand )
{
this.name = name;
this.kontoStand = kontoStand;
}
}
Bank :
package monopoly.actors;
public class Bank extends Actor
{
int house = 32;
int hotel = 16;
public Bank()
{
super(" banken ",10000000);
}
public String getName()
{
return this.name;
}
}
2. spieler :
package monopoly.actors;
import monopoly.fields.*;
import monopoly.game.*;
import java.util.*;
public class Player extends Actor implements PlayerInterface
{
private Bank bank;
private ArrayList fieldList;
private Field fieldStart;
private Field currentField;
public Player( String name, int kontoStand, Field fieldStart, Field currentField )
{
super(name,kontoStand);
this.bank = bank;
fieldList = new ArrayList();
this.fieldStart = fieldStart;
this.currentField = currentField;
}
public String getName()
{
return this.name;
}
public void youTurn(Dice dice)
{
dice.throwDice();
int n = dice.sum();
System.out.println( " Spieler"+ name +"_ hat gewurfelt" + n );
}
public int getBalance()
{
return this.kontoStand;
}
public FieldInterface getCurrentField()
{
return this.currentField;
}
public Iterator getPropertyIterator()
{
return fieldList.iterator();
}
}
3. Field :
package monopoly.fields;
import monopoly.actors.*;
public class Field implements FieldInterface
{
protected String name;
protected int index;
protected Bank bank;
public int getIndex()
{
return this.index;
}
public String getName()
{
return this.name;
}
}
monopolygame :
package monopoly.game;
import monopoly.fields.*;
import monopoly.actors.*;
import simpleInput.*;
import monopoly.support.*;
class MonopolyGame
{
Field fieldStart;
Field currentField;
Player [] playerArray;
Dice dice;
MonopolyGUI gui;
public static void main (String [] args )
{
MonopolyGame monoGame = new MonopolyGame();
System.out.println("Spiel erzeugt");
monoGame.start();
}
4. public MonopolyGame()
{
gui = new MonopolyGUI();
System.out.println("konstruktor");
SimpleInput input = new SimpleInput();
System.out.println("Bitte Spielerzahl eingeben");
int zahl = input.nextInt();
if ( zahl > 6 )
{
System.out.println( " Muss kleiner oder gleich als 6 " );
}
else
{
playerArray = new Player[zahl];
for(int i = 0; i < zahl; i++)
{
Player player = new Player ( " spieler " + i+1, 1500, fieldStart, currentField );
playerArray [i] = player;
gui.registerPlayer(player);
}
}
Bank bank = new Bank ();
}
public void start()
{
int i = 0;
dice = new Dice();
while( true )
{
playerArray[i].youTurn(dice);
i++;
if(i == playerArray.length)
{
i = 0;
}
}
}
}