Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #52050

Re: Creating a running tally/ definitely new to this

Newsgroups comp.lang.python
Date 2013-08-06 08:24 -0700
References <9e9e6a5a-5f8e-46b4-91dc-757fc74348d9@googlegroups.com> <mailman.226.1375755352.1251.python-list@python.org>
Message-ID <8b372a3b-c71d-4e26-88ae-ce5e6239fc36@googlegroups.com> (permalink)
Subject Re: Creating a running tally/ definitely new to this
From gratedmedia@gmail.com

Show all headers | View raw


On Monday, August 5, 2013 10:15:30 PM UTC-4, Dave Angel wrote:
> gratedmedia@gmail.com wrote:
> 
> 
> 
> >
> 
> > I currently working on a game, where I need to maintain a running tally of money, as the player makes purchases as they navigate thru game.   I not exactly sure how to do this in python.  I know it is a fairly basic step, nonetheless.  Any assistance would be greatly appreciated.  
> 
> 
> 
> (just to save you the pain later:
> 
>    http://wiki.python.org/moin/GoogleGroupsPython
> 
> )
> 
> 
> 
> So what have you written so far?  Is this a homework assignment and
> 
> you've been covering certain parts of Python in a certain order? Is it
> 
> part of learning some tutorial?
> 
> 
> 
> There are so many ways of accomplishing this sort of thing, that without
> 
> some constraints, there are a dozen reasonable responses.  I'll try one:
> 
> 
> 
> in the class Player, you make a pair of methods, purchase() and
> 
> income(), which manipulate the instance attribute assets.   Then you
> 
> make a property that returns the assets.
> 
> 
> 
> 
> 
> 
> 
> Class Player:
> 
>      ....
> 
>      def purchase(self, amount):
> 
>         self.assets -= amount
> 
>      def income(self, amount):
> 
>         self.assets += amount
> 
>      def wealth(self):
> 
>         return self.assets
> 
> 
> 
> 
> 
> -- 
> 
> DaveA

This a project I am am working on.  I am using "Learn Python the Hard Way". To best explain. I'm working on a game with a similar format to John Dell's Dopewars, but on Python. SO I've created the several destinations to travel, but now maintaining the "running tally (money)" has been my issue. I'm going to take your advice and play with code you posted.  Please contact me with any more suggestions.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Creating a running tally/ definitely new to this gratedmedia@gmail.com - 2013-08-05 18:01 -0700
  Re: Creating a running tally/ definitely new to this Joshua Landau <joshua@landau.ws> - 2013-08-06 02:56 +0100
    Re: Creating a running tally/ definitely new to this gratedmedia@gmail.com - 2013-08-06 04:00 -0700
  Re: Creating a running tally/ definitely new to this Dave Angel <davea@davea.name> - 2013-08-06 02:15 +0000
    Re: Creating a running tally/ definitely new to this gratedmedia@gmail.com - 2013-08-06 08:24 -0700
      Re: Creating a running tally/ definitely new to this Joshua Landau <joshua@landau.ws> - 2013-08-07 13:02 +0100

csiph-web