On Sun, Oct 11, 2009 at 2:42 PM, shellc...@juno.com <shellc...@juno.com>wrote:

> I want to display the ship default value for zero and display the ship's
> initial fuel level. Also have a method called status that displays an
> object's name and  fuel values. I want to have several Ship objects and call
> their status() methods to test various aspects of the class constructor.
>

And what problems have you run into? What would you like from us? This
sounds vaguely like homework which we don't do here. We are, however, more
than happy to offer pointers in the right direction if you get stuck.

For an explanation of /how/ to ask a good question, check out this:
http://catb.org/~esr/faqs/smart-questions.html#examples

HTH,
Wayne


>
> Here's my code:
>
>                   class Ship(object):
>    """A spaceship"""
>    total = 0
>    def __init__(self, name, fuel = 0):
>
>        print "My spaceship has arrived! The",name
>        self.name = name
>        self.fuel = fuel
>
>        print "My fuel level is", fuel
>
>    def status():
>        Ship.total += 1
>        print "The total number of objects is", Ship.total
>    status = staticmethod(status)
>
> #main
> ship = Ship("Galaxia")
>
> print "\nCreating objects."
> ship1 = Ship("object 1")
> ship2 = Ship("object 2")
> ship3 = Ship("object 3")
> Ship.status()
>
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to