Hello everyone I need to create a project in Java that will
Hello everyone, I need to create a project in Java that will satisfy the following rules:
For Monster class implement the load() from Loadable, the data fields should be in this order: x, y, health and read each data field in with nextInt().
For Orc class implementation of drawToMap() from Drawable , if screen is null draw ‘o’ at(x,y) of screen.
For Spider’s class implementation of drawToMap() from Drawable, if the screen is null draw ‘s’ at(x,y) of screen.
Modify the Map class to implement Loadable. For Map’s implementation of load() from Loadable: set mapData to new char[0][0] and mapRows/mapCols to zero. The number of rows and columns will be on separate lines. Read in each line (nextLine()), convert it to an int (using Integer.parseInt()), and store these values in mapRows and mapCols. Reallocate space for mapData based on new current rows and columns. For each row, read in each line as a String, and store the characters in the String as the characters in each row of mapData. Add a no-arg constructor that sets mapData to new char[0][0] and mapRows/mapCols to zero.
Write class Main with a main method. The code must be in try block. Ask the user which level number they want and put the String they enter into a String “levelName”. Open file “Map” + levelName + “.txt” with a Scanner object and create a Map instance called baseMap and call its load() method on this Scanner. Open file “Monster” + levelName + “.txt” using a Scanner inputMonsters. Read in the number of monsters using nextInt().Create an ArrayList of Monsters.
For each monster: read in type as a String using next(). It will either be ”Orc” or ”Spider”, declare a variable of type Monster called m, if the type is ”Orc”, create an instance of Orc and put it in m, if the type is ”Spider”, create an instance of Spider and put it in m, if m isn’t null, call its load() method, and add it to the list of Monsters.
Loop through all monsters and call drawToMap(), passing in baseMap. Draw baseMap to console. Catch Exception, print message ”Game error” to STDERR, and print stack trace.
There are two sets of files available to download for testing:
”01” set:
http://web.cs.sunyit.edu/~realemj/2016fall/Map01.txt
http://web.cs.sunyit.edu/~realemj/2016fall/Monsters01.txt
”02” set:
http://web.cs.sunyit.edu/~realemj/2016fall/Map02.txt
http://web.cs.sunyit.edu/~realemj/2016fall/Monsters02.txt
OUTPUT for ”01”:
####################
# . . . . . . . . . . . . . . . . . . #
# . . o . . . . . . . . . . . . . . . #
# . . . . . . . . . # # # . . . . . . #
# # # . . . . . . . # # . . . s . . #
# . . . . . . . # # . . . . . . #
######### ########
OUTPUT for ”02”:
#############
# . . o . . . . . . . . #
# . . . . . . . . . . . #
# . . . . . . . s . . . #
#####. s . . . . . #
# . . . . . . . #
# . . . . o . . #
#########
Here is the code that I have so far
//Drawable
//Loadable
//Map
//Monster
//Orc
//Spider
Solution
OUTPUT
Which level number you want?
01
####################
# . . . . . . . . . . . . . . . . . . #
# . . o . . . . . . . . . . . . . . . #
# . . . . . . . . . # # # . . . . . . #
# # # . . . . . . . # # . . . s . . #
# . . . . . . . # # . . . . . . #
######### ########
Which level number you want?
02
#############
# . . o . . . . . . . . #
# . . . . . . . . . . . #
# . . . . . . . s . . . #
#####. s . . . . . #
# . . . . . . . #
# . . . . o . . #
#########
Main.java
Map.java
Monster.java
Orc.java
Spider.java


