__author__ = 'bailey'

class Typical :
    niftyTotal = 0 # this is a data field belong to the class rather than to individual objects
                # such data fields share their values amongst all objects, though should be
                # accessed from the class name rather than from any particular object

    def __init__(self, name = "Joe", height = 2):
        '''
        :param name: is a data field owned by individual objects, so having distinct values
        :param height:
        :param id: is set automatically to be incremented on building each object
        :param others: is to hold a list to be populated by the add2others method
        '''
        if isinstance(name, str) : # checking to see if whatever had been fed in was a string
            self.name = name
        else:
            self.name = "Mary"
        self.height = height
        self.id = Typical.niftyTotal
        self.others = []
        Typical.niftyTotal += 1

    def getName(self):
        return self.name

    def setName(self, name):
        self.name = name

    def isEmpty(self):
        return len(self.others) == 0

    def add2others(self, goofy):
        self.others.append(goofy)

    def __str__(self): # to allow easy printing of information about objects
        temp = "My name = " + self.name + ", height = " + str(self.height) + ", id = " + str(self.id)
        temp += "\n\tand the value of niftyTotal = " + str(self.niftyTotal)
        return temp

    def showOthers(self): # a quick method to print the contents of the others list
        if self.isEmpty() :
            print(self.name + " doesn't have any others ...")
            return
        print(self.name + "'s others are ...")
        for each in self.others :
            print(each)

## now to use this stuff
a = Typical("abe", 2.3)
b = Typical("beth", 2.5)
c = Typical("carol", 1.7)
d = Typical("davidd")
e = Typical("evanovitch", 2.9)
f = Typical(1.9)
crowd = [a]
crowd.append(b)
crowd.append(c)
crowd.append(d)
crowd.append(e)
crowd.append(f)
a.add2others(b)
a.add2others(c)
for folk in crowd :
    print(folk)
a.showOthers()
b.showOthers()
