Hi there I am doing a assignment and the code should be simple as soon as I
get
what the question is meaning.

The assignment is

Create *Inventory class* that tracks different types of coconuts from
around the world. The different types of coconuts must have these weight
attribute values:

Type

Weigt

South Asian

3

Middle Eastern

2.5

American

3.5

The inventory class must have the following methods:

   -

   add_coconut() accepts a coconut as an argument. Other types throw an
   AttributeError.

total_weight() provides the total weight of coconuts.


The code that I am thinking of now is below

class Inventory(object):
    def __init__(self):
        self.coconuts = []

    def add_coconut(self, cocoType):
        if not isinstance(cocoType, Inventory):
            raise AttributeError("%s isn't type of Coconut can be
added"(cocoType))
        self.coconuts.append(cocoType)

    def total_weights(self):
        totalWeight = 0.0
        for each in coconuts:
            totalWeight += each.weight


class Coconut(object):
    weight = 0.0

class SouthAsian(Coconut):
    weight = 3.0

class MiddleEastern(Coconut):
    weight = 2.5

class American(Coconut):
    weight = 3.5



Thank you so much for your help!

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to