コード例 #1
0
def main():
    """Program to demonstrate trees of different types."""
    # Let's make some trees of different classes (subclasses)
    tree_list = [
        trees.Tree(),
        trees.EvenTree(),
        trees.UpsideDownTree(),
        trees.WideTree(),
        trees.QuickTree(),
        trees.FruitTree(),
        trees.PineTree()
    ]

    # display all the trees
    for tree in tree_list:
        print(tree.__class__)
        print(tree)

    print("Time to grow!")
    # grow them several times
    for _ in range(5):
        for tree in tree_list:
            tree.grow(5, 2)

    # display all the trees again
    for tree in tree_list:
        print(tree.__class__)
        print(tree)
コード例 #2
0
def main():
    """Program to demonstrate trees of different types."""
    tree_list = [trees.Tree(), trees.EvenTree(), trees.UpsideDownTree(),
                 trees.WideTree(), trees.QuickTree(), trees.FruitTree(),
                 trees.PineTree()]

    # display all the trees
    for tree in tree_list:
        print(tree.__class__)
        print(tree)

    print("Time to grow!")
    for _ in range(5):
        for tree in tree_list:
            tree.grow(5, 2)

    for tree in tree_list:
        print(tree.__class__)
        print(tree)
コード例 #3
0
ファイル: trees_tester.py プロジェクト: carakaxangkaka/CP1404
def main():
    tree_list = [trees.Tree(), trees.EvenTree(), trees.UpsideDownTree(),
                 trees.WideTree(), trees.QuickTree(), trees.FruitTree(),
                 trees.PineTree()]

    # display all the trees
    for tree in tree_list:
        print(tree.__class__)
        print(tree)

    print("Time to grow!")
    # grow them several times
    for _ in range(5):
        for tree in tree_list:
            tree.grow(5, 2)

    # display all the trees again
    for tree in tree_list:
        print(tree.__class__)
        print(tree)