# L-36 MCS 260 Mon 11 Apr 2016 : class_threadfrog.py

"""
The script simulates hopping frogs via threads,
inheriting from Thread and Frog.
"""

from threading import Thread
from class_frog import Frog

class ThreadFrog(Thread, Frog):
    """
    Exports hopping frogs as threads.
    """
    def __init__(self, n, x, y, h, d, m):
        """
        A frog with name n at (x,y)
        makes m hops of size at most h,
        resting at most d seconds.
        """
        Thread.__init__(self, name=n)
        Frog.__init__(self, n, x, y, h, d, m)

    def run(self):
        """
        The frog does as many moves
        as the value set by self.moves.
        """
        while self.hop_limit > 0:
            self.hop()
            self.hop_limit = self.hop_limit - 1

def main():
    """
    Runs a simple test on hopping frogs.
    """
    print('creating two frogs: a and b')
    ann = ThreadFrog('a', +10, +10, 5, 2, 4)
    bob = ThreadFrog('b', -10, -10, 15, 5, 3)
    print('starting the hopping ...')
    ann.start()
    bob.start()
    print('waiting for frogs to finish ...')
    ann.join()
    bob.join()

if __name__ == "__main__":
    main()
