Course web page: Introduction to Computer Science for majors II James Tam | Return to the course web page |
Tuesday October 27 at 4 PM
Write a simple fantasy-oriented combat simulation between an orcish and dwarven forces.
Figure 1: Orcs
vs. dwarves
The starting positions will be read in from a text file "data.txt". Figure 2 shows the text file as viewed from MS-Word (where the 'invisible' spaces are shown as dots).
Figure 2:
default contents of the
data.txt file.
While you can change the contents of the starting file for testing make sure that it always remains 10 characters by 10 characters in size. You must ensure that 'empty' locations are still filled with spaces! Be aware that your markers may produce different versions of input files for testing purposes. They will all conform to the basic requirements (10x10, valid characters will consist only of: 'O', 'D' or spaces) but your program should be able to properly handle anything that they come up with.
The position of a character in the text file will correspond to the position of an array of "Entity" in your program. (Figure 3) Each 'O' in the text file becomes an orcish fighter while the 'D' becomes a dwarven warrior. Both are instances of the Entity class each with a difference appearance and different health or "hit point" scores (10 for the orcs and 15 for the dwarves). Empty spaces will become null elements in the array.
Figure 3: starting
view of the game world
You must use the pre-created code in the FileInitialization.class file to read the text information into the 2D Entity array (ensuring that the byte code .class file is the same directory as your source code *.java files and the "input.txt" data file.
public class
FileInitialization