shanenin Posted July 21, 2005 Report Share Posted July 21, 2005 (edited) I am having a tough time understanding what is going on in this following codeclass Player(object): """ A player in a shooter game. """ def blast(self, enemy): print "The player blasts an enemy.\n" enemy.die()class Alien(object): """ An alien in a shooter game. """ def die(self): print "The alien gasps and says, 'Oh, this is it. This is the big one. \n" \ "Yes, it's getting dark now. Tell my 1.6 million larvae that I loved them... \n" \ "Good-bye, cruel universe.'"# mainprint "\t\tDeath of an Alien\n"hero = Player()invader = Alien()hero.blast(invader)in particular this line hero.blast(invader)how is the object invader interacting the the blast method? Edited July 21, 2005 by shanenin Quote Link to post Share on other sites
jcl Posted July 21, 2005 Report Share Posted July 21, 2005 (edited) The blast() method takes takes an alien (or whatever) as its sole argument, prints a message, and then calls alien's die() method. Not much more too it. Edited July 21, 2005 by jcl Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.