Dungeon

193 views
Skip to first unread message

mr_evil

unread,
Sep 10, 2015, 5:09:28 AM9/10/15
to mooc.fi
Hi,

I'm having problems with week 10 exercise 33.

I have 2 problems concerning the exercise:

1. I am trying to print correct number of dot where vampire occupied the dot. For example, the row having 1 vampire will have one more dot more than usual. That is because of the if-statement  I wrote. 
2. The method runIntoPlayer() seems not to work as I expect. Probably I accidentally create a loop trap , as player collides with vampire, the game does not move to next round.


Best regards


Supported languages are English and Finnish

Please use our build in TMC Pastebin when asking questions related to your code  
 
TMC Plugin has built-in code sharing feature. 
In NetBeans, select TMC -> Send code to TMC pastebin. Copy the link you receive and paste it to your message.  

You may use our web interface to share code snippets: http://paste.mooc.fi

mr_evil

unread,
Sep 10, 2015, 5:13:16 AM9/10/15
to mooc.fi
One more problem is that I dont understand the role of boolean value vampiresMove in the constructor. 

Juho Leinonen

unread,
Sep 14, 2015, 3:09:47 AM9/14/15
to mooc.fi
Hello,

The first problem happens because you don't check if you have printed a 'v' for a vampire already, so you will always print a '@' or a '.' even if you printed a 'v' for the same spot. A way to solve this problem would be to somehow remember if something was printed for this position already, for example by using a boolean variable.

The second problem is because you are removing something from the list while iterating through it. In Java, you cannot modify a list while iterating through it. A way to go around this limitation is to add the vampires that should be removed into another temporary list, and after the for-loop, use list.removeAll(temporaryList) to remove the vampires.

The role of the vampiresMove is to control whether the vampires should move or not. If it is set to false, the vampires should stay still.

Hope you will be able to continue with these hints :)

Best regards,
Juho

mr_evil

unread,
Sep 14, 2015, 7:21:21 AM9/14/15
to mooc.fi
Thanks for you hints, I have solved those 2 problems but then I dont know how to use the boolean vampiresMove in the game. Why do we need this variable ? If this is set to be True, the game  will run as normal , otherwise, the vampire will not move at all during all the turns ?


On Thursday, September 10, 2015 at 11:09:28 AM UTC+2, mr_evil wrote:

Juho Leinonen

unread,
Sep 14, 2015, 9:18:44 AM9/14/15
to mooc.fi
Hello,

Yes, if the variable is set to false, the vampires should not move at all.

Best regards,
Juho

Reply all
Reply to author
Forward
0 new messages