O'Reilly Forums: Lab #2: The Quest - O'Reilly Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Lab #2: The Quest

#1 User is offline   darivuki 

  • New Member
  • Pip
  • Group: Members
  • Posts: 7
  • Joined: 18-March 14

Posted 01 July 2014 - 06:41 AM

Hi to everyone!

I'm having trouble understanding the architecture of the Lab #2: The Quest project.
If the Game class keeps track of everything that is happening, and only that class is exposed to the form,
why do Enemy, Player and Mover classes have such a class reference in their constructor?

Thank you for helping :)

I'm reading the 3rd edition.
0

#2 User is offline   AndrewStellman 

  • Andrew Stellman
  • PipPipPipPipPipPipPipPipPipPipPip
  • Group: O'Reilly Author
  • Posts: 757
  • Joined: 08-October 08
  • Gender:Male
  • Location:Brooklyn, NY
  • Interests:Author of: "Head First C#", "Beautiful Teams", "Head First PMP", "Applied Software Project Management"

Posted 01 July 2014 - 04:52 PM

That's a great question -- it's really good that you're thinking about how the objects relate to each other, and about what information they have available to them.

The Enemy objects need to know where the player is because they move towards him, so their Move() methods need to know the player's location. They'll use the game.PlayerLocation property for that. When the player attacks, the Player object's Attack() method needs to know where the enemies are, so it will use the game.Enemies property to locate them.

I hope this helps!
Andrew Stellman
Author, Head First C#
Building Better Software -- http://www.stellman-greene.com
0

#3 User is offline   darivuki 

  • New Member
  • Pip
  • Group: Members
  • Posts: 7
  • Joined: 18-March 14

Posted 03 July 2014 - 10:06 AM

This makes sense.

I'm just a little bit confused how this architecture works. There is a lot going on. Objects are constantly updated with new information.

I can't wait to use the debugger tool on the finnished project to see how these objects communicate with each other. :huh:
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users