<div class="gmail_quote">On Sun, Oct 11, 2009 at 2:42 PM, <a href="mailto:shellcom3@juno.com">shellcom3@juno.com</a> <span dir="ltr"><<a href="mailto:shellcom3@juno.com">shellcom3@juno.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
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.<br>
</blockquote><div><br></div><div>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.</div>
<div><br></div><div>For an explanation of /how/ to ask a good question, check out this: <a href="http://catb.org/~esr/faqs/smart-questions.html#examples">http://catb.org/~esr/faqs/smart-questions.html#examples</a></div><div>
<br></div><div>HTH,</div><div>Wayne</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
Here's my code:<br>
<br>
class Ship(object):<br>
"""A spaceship"""<br>
total = 0<br>
def __init__(self, name, fuel = 0):<br>
<br>
print "My spaceship has arrived! The",name<br>
<a href="http://self.name" target="_blank">self.name</a> = name<br>
self.fuel = fuel<br>
<br>
print "My fuel level is", fuel<br>
<br>
def status():<br>
Ship.total += 1<br>
print "The total number of objects is", Ship.total<br>
status = staticmethod(status)<br>
<br>
#main<br>
ship = Ship("Galaxia")<br>
<br>
print "\nCreating objects."<br>
ship1 = Ship("object 1")<br>
ship2 = Ship("object 2")<br>
ship3 = Ship("object 3")<br>
Ship.status()<br></blockquote><div><br></div><div> </div></div>