import java.util.Scanner; /* Author: James Tam Version: October 12, 2015 Features implemented: * Reads start positions from the file "data.txt" * (Input file must be in the curent working directory). * Array is initialized based on these starting positions and world is displayed once. To-do: * All other program requirements specified in the assignment description. */ public class World { public static final int SIZE = 10; public static final int START = 1; private Entity [][] aWorld; private int currentRow; private int currentColumn; // Post-condition: the position of the characters in the // starting input file will determine the position of the // objects in the array. The type of character in the file // determines the appearance of the Entity(O or D) or if the // element is empty (spaces become null elements) public World() { aWorld = new Entity[SIZE][SIZE]; int r; int c; for (r = 0; r < SIZE; r++) { for (c = 0; c < SIZE; c++) { aWorld[r][c] = null; } } aWorld = FileInitialization.read(); } // Displays array elements on at a time one row per line // Each element is bound above, below, left and right by // bounding lines public void display() { int b; int r; int c; for (r = 0; r < SIZE; r++) { for (b = 0; b < SIZE; b++) System.out.print(" -"); System.out.println(); for (c = 0; c < SIZE; c++) { if(aWorld[r][c] == null) System.out.print("| "); else System.out.print( "|" + aWorld[r][c].getAppearance()); } System.out.println("|"); } for (b = 0; b < SIZE; b++) System.out.print(" -"); System.out.println(); } // Shows the position of the Entities immediately after // file initialization has occured. It's up the student // to fill in the rest of the program! public void start() { display(); } }