Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Main {
- public static void main(String[] args) {
- System.out.println("Hello world!");
- //maak een game object
- //run de game totdat het klaar is. (vol of winnende zet is gezet)
- }
- }
- class VORGame{
- int[][] bord;
- // Een bordpositie heef waarde 0 als leeg, 1 of twee voor de respectievelijke spelers-stenen.
- public VORGame(){
- // dit is de constructor. Het bord wordt klaargezet.
- initBord();
- }
- public void initBord(){
- bord = new int[5][5];
- for (int i=0;i<5;i++){
- for (int j=0;j<5;j++){
- bord[i][j]=0;
- }
- }
- }
- public boolean bevatVOR(){
- // voor alle posities :
- // - check horizontale VOR
- // - check verticale VOR
- // - check diagonale VOR
- return false;
- }
- public void playTurn(){
- // doe een beurt:
- /*
- - CHECK of bord vol is. Indien niet :
- - vraag speler een om een kolomnnummer
- - plaatsSteen in kolom met juiste kleur
- - als dit een bevatVOR == true oplevert ==> WINNAAR
- Indien geen winnaar :
- - vraag speler twee om een kolomnnummer
- - plaatsSteen in kolom met juiste kleur
- - als dit een bevatVOR == true oplevert ==> WINNAAR
- KLAAR
- */
- }
- /**
- * Does a move based on the requested column and the team that plays
- * the move. It will check at what height the move will end, places
- * this inside of the 'bord' and forces the board to redraw
- *
- * @param column the column that is played
- * @param team the team that makes the move
- * @since 1.0
- */
- public void plaatsSteen(int column, int team){
- int placement = getLowestEmptySpace(bord[column]);
- if(placement != -1) {
- bord[column][placement] = team;
- } else {
- throw new ColumnAlreadyFilledException(column);
- }
- tekenBord();
- }
- /**
- * Gets the lowest possible space inside of a row
- *
- * @param column the column that should be checked on an empty space
- * @return the lowest possible empty space. If the row is completely
- * filled, it will return -1
- * @since 1.0
- */
- private int getLowestEmptySpace(int[] column) {
- for(int i = 0; i < column.length; i++) {
- if(column[i] == 0) {
- return i;
- }
- }
- return -1;
- }
- public void tekenBord() {
- // teken het bord naar het scherm
- }
- }
- /**
- * This Exception can be thrown when a column is played when the column
- * is already completely filled
- *
- * @author Mark van Wijk
- * @since 1.0
- */
- class ColumnAlreadyFilledException extends RuntimeException {
- /**
- * Adds a message to the Exception so that it will be possible for
- * Dutch people to understand why this Exception is thrown
- *
- * @param column the filled column
- * @since 1.0
- */
- ColumnAlreadyFilledException(int column) {
- super("De kolom " + column + " is al volledig gevult");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement