On 18-May-10 17:51 PM, Alex Hall wrote:
Hi again all,
More about classes. I am still looking into my battleship game, and I
will have several different craft. All craft have common attribs
(position, alive, and so on) but each craft may be a surface ship,
submarine, or airplane. All three are cra
Dave Angel wrote:
Inside the __init__() method of Submarine, simply call the __init__()
method of Craft, with appropriate parameters.
To elaborate on that a little, it looks like this:
class Craft:
def __init__(self, position):
self.position = position
class Submarine(Craft):
Alex Hall wrote:
So by calling submarine(craft) I am bringing
in all of craft's attribs (subclassing)? Or does calling craft's
__init__ method do that instead?
By making Submarine a subclass of Craft, you are inheriting
any methods, or other class attributes, defined in the
classes themselves.
Alex Hall wrote:
Sorry, top-posting is a habit on some other lists I am on, and
sometimes it follows me to lists where in-line posting is the way to
do it.
Which list you're on shouldn't matter. You should cultivate
the habit of always quoting selectively and minimally, on
any list. It may tak
On 5/18/10, Dave Angel wrote:
> Alex Hall wrote:
>> Okay, that makes sense. So by calling submarine(craft) I am bringing
>> in all of craft's attribs (subclassing)? Or does calling craft's
>> __init__ method do that instead? Is there an advantage to doing it
>> this way, rather than just making se
Alex Hall wrote:
Okay, that makes sense. So by calling submarine(craft) I am bringing
in all of craft's attribs (subclassing)? Or does calling craft's
__init__ method do that instead? Is there an advantage to doing it
this way, rather than just making separate classes for everything,
except for m
Okay, that makes sense. So by calling submarine(craft) I am bringing
in all of craft's attribs (subclassing)? Or does calling craft's
__init__ method do that instead? Is there an advantage to doing it
this way, rather than just making separate classes for everything,
except for my own sense of orga
Alex Hall wrote:
Hi again all,
More about classes. I am still looking into my battleship game, and I
will have several different craft. All craft have common attribs
(position, alive, and so on) but each craft may be a surface ship,
submarine, or airplane. All three are craft, but a submarine can
Hi again all,
More about classes. I am still looking into my battleship game, and I
will have several different craft. All craft have common attribs
(position, alive, and so on) but each craft may be a surface ship,
submarine, or airplane. All three are craft, but a submarine can be
submerged or no