# Filename: OrangutanDave.py
# Title: Dave the Orangutan
# Function: Creates an object (an orangutan called Dave) and gives it the
# co-ordinates (2,2). The program then displays how far (in a straight line)
# 'Dave' is from the point (5,3) where his favourite food is.
# Author: Philip Burling
# Date: 28/04/07

# This line imports the class 'OrangUtan' from the file 'OrangUtan.py' (which
# should be in the same directory) along with its associated functions.

from OrangUtan import *

# This line creates the object 'Dave' of the class 'OrangUtan' and assigns it a
# name, x co-ordinate and y co-ordinate.

Dave = OrangUtan("Dave", 2, 2)

# This line prints the distance (as the crow flies) that Dave is from the
# location of the food at (5,3). It finds this distance by calling the function
# 'distanceFrom' from the imported rules from the file 'OrangUtan.py'

print "Dave is", Dave.distanceFrom(5, 3), "units from his food"
while x2 == '':
    try:
        x2 = input('Enter the x co-ordinate of the second Orangutan: ')
        print ''
    except:
        print ''
        print 'Error!. Entry must consist solely of digits.'
        print ''

while y2 == '':
    try:
        y2 = input('Enter the y co-ordinate of the second Orangutan: ')
        print ''
    except:
        print ''
        print 'Error!. Entry must consist solely of digits.'
        print ''

# The following section constructs the two 'OrangUtan' objects ('O1' and 'O2')
# from the collected data.

O1 = OrangUtan(name1,x1,y1)
O2 = OrangUtan(name2,x2,y2)

# The next section uses a function associated with the 'OrangUtan' class to find
# the distance between two 'OrangUtan' objects 'O1' and 'O2'.

print name1, 'is', O1.distanceFrom(O2.getX(),O2.getY()), 'units from', name2
print ''
raw_input('<<< Press Enter to exit >>>')