Exemplo n.º 1
0
 def post(self):
     dog_data = dog.Dog()
     dog_data.d_o_email = users.get_current_user().email()
     dog_data.d_name = str(self.request.get('name'))
     dog_data.d_age = int(self.request.get('age'))
     dog_data.d_gender = str(self.request.get('gender'))
     dog_data.d_breed = str(self.request.get('breed'))
     dog_data.insertToDb()
     self.redirect('/owner-home')
Exemplo n.º 2
0
 def __init__(self, num_of_dogs):
     '''
     description: 
     param {int} 
     return: 
     '''
     for n in range(num_of_dogs):
         try:
             self.dogs.append(dog.Dog())
         except:
             print('error: Can not add this dog')
         else:
             print('Successfully added a dog.')
Exemplo n.º 3
0
 def getAllDogs(self, email):
     self.d_DbHandler.connectToDb()
     cursor = self.d_DbHandler.getCursor()
     cursor.execute("SELECT * FROM dog WHERE o_email LIKE %s;", (email, ))
     dog_records = cursor.fetchall()
     for dog_record in dog_records:
         current_dog = dog.Dog()
         current_dog.d_id = dog_record[0]
         current_dog.d_name = dog_record[2]
         current_dog.d_ownerEmail = dog_record[1]
         self.d_RetrievedDogsList.append(current_dog)
     self.d_DbHandler.disconnectFromDb()
     return self.d_RetrievedDogsList
Exemplo n.º 4
0
import dog

my_dog = dog.Dog('Willie', '6')

print(my_dog.name, my_dog.age)
my_dog.sit()
Exemplo n.º 5
0
import dog

print("=============================")

my_dog = dog.Dog("willie", 6)

print("My dog's name is " + my_dog.name.title() + ".")
print("My dog is " + str(my_dog.age) + " years old.")

my_dog.sit()
my_dog.roll_over()

Exemplo n.º 6
0
 def topic(self):
     name = random_name.full_name()
     age = randint(18, 30)
     return dog.Dog(name, age)
Exemplo n.º 7
0
import dog
import pack

my_dog = dog.Dog("Spot")
my_dog.print_name()
my_dog.sit()
my_dog.roll_over()
my_dog.print_trick_list()

my_pack = pack.Pack(my_dog)
print(my_pack.get_leader_name())
dog_2 = dog.Dog("Fido")
dog_3 = dog.Dog("Rover")

my_pack.add_member(dog_2)
my_pack.add_member(dog_3)

my_pack.print_pack()

Exemplo n.º 8
0
import dog

my_other_dog = dog.Dog("Annie", "SuperDog")
my_other2_dog = dog.Dog("Steph", "AwesomeDog")
my_other3_dog = dog.Dog("Mike", "RadDog")
print(my_other3_dog.bark())
print(my_other2_dog.sit())
print(my_other_dog.rollover())
#! /usr/bin/env python

import dog

myDog = dog.Dog('Hundi')
myDog.bark()
Exemplo n.º 10
0
# Abstract keyword is not supported in python, so we have to use this trick

# I want to force sub classes (i.e dog and cat) to have their own speak method, and get an error if they dont

import dog, cat

# the below will throw an error to show the class can't be instantiated
#anim = animal.Animal()

# all good here
dg = dog.Dog('Bingo')

dg.speak()

ct = cat.Cat('Fluffy')
ct.speak()
Exemplo n.º 11
0
import dog

my_dog = dog.Dog("Alex", "Chiwawa")
print("Dogs name: {}".format(my_dog.name))
print("Dogs breed: {}".format(my_dog.breed))
my_dog.bark()

my_other_dog = dog.Dog("Annie", "SuperDog")
print("Dogs name: {}".format(my_other_dog.name))
print("Dogs breed: {}".format(my_other_dog.breed))
my_other_dog.bark()
Exemplo n.º 12
0
import dog

sugar = dog.Dog("Sugar", "border collie")
print(sugar.name)
print(sugar.breed)
print(sugar.tricks)

sugar.teach("frisbee")
sugar.knows("frisbee")
sugar.knows("arithmetic")
Exemplo n.º 13
0
# from dog import Dog
import dog


my_dog = dog.Dog("Ziggy")
my_dog.bark()
Exemplo n.º 14
0
def main():
    try:
        with open('pets.csv', 'r') as f:
            reader = csv.reader(f)
            your_list = list(reader)
            for i in range(0, len(your_list)):
                if your_list[i][0] == 'Dog':
                    d = dog.Dog(your_list[i][1], your_list[i][2], your_list[i][3],your_list[i][4])
                    name_list.append(d.name)
                elif your_list[i][0] == 'Cat':
                    c = cat.Cat(your_list[i][1], your_list[i][2], your_list[i][3], your_list[i][4])
                    name_list.append(c.name)
                elif your_list[i][0] == 'Fish':
                    f = fish.Fish(your_list[i][1], your_list[i][2], your_list[i][3], your_list[i][4])
                    name_list.append(f.name)
                elif your_list[i][0] == 'Bird':
                    b = bird.Bird(your_list[i][1], your_list[i][2], your_list[i][3], your_list[i][4])
                    name_list.append(b.name)


        # Show only pets of a certain type # Based on the user input, show only the pets that are dogs/cats/fish/birds.
        def animal_type(enter):
            for i in range(0, len(your_list)):
                if your_list[i][0] == enter.title():
                    print('-', your_list[i][3])
            return ''


        # Search for a Pet -
        # you will call your own binary search function to search for the first pet name that matches the user entered string.
        # If a pet is found in the list, then print all the details for that pet and the index in the list where it was found.
        # If the pet is not in the list, then print a message informing the user that the pet is not in the list.
        def search(enter):
            low = 0
            high = len(your_list)-1
            insertion_sort_name(your_list)
            while low <= high:
                mid = int((low + high) / 2)
                if ' ' + enter.title() == your_list[mid][1]:
                    print("The index is " + str(mid) + " in the list.")
                    return your_list[mid]
                elif ' ' + enter.title() < str(your_list[mid][1]):
                    high = mid - 1
                else:  # enter > your_list[mid]
                    low = mid + 1
            return 'The pet is not in the list.'


        # Sort list based on pet name -
        # For all the sort options you can implement either selection sort or insertion sort on the list of pet objects.
        # After sorting the list, display the sorted list.
        def insertion_sort_name(list):
            keyIndex = 1
            while keyIndex < len(list):
                insert_nameorder(list, keyIndex)
                keyIndex += 1

        def insert_nameorder(list, keyIndex):
            key = list[keyIndex][1]
            j = keyIndex -1
            while (list[j][1] >= key) and (j >= 0):
                list[j + 1][1] = list[j][1]
                j -= 1
                list[j + 1][1] = key


        # Sort list based on pet color - After sorting the list, display the sorted list.
        def insertion_sort_color(list):
            keyIndex = 1
            while keyIndex < len(list):
                insert_colororder(list, keyIndex)
                keyIndex += 1

        def insert_colororder(list, keyIndex):
            key = list[keyIndex][4]
            j = keyIndex - 1
            while (list[j][4] >= key) and (j >= 0):
                list[j + 1][4] = list[j][4]
                j -= 1
                list[j + 1][4] = key

        print('Your Pet Finder menu: ')
        print('===========================')
        enter1 = 0
        while enter1 != 6:
            print('1. Display the names of all the pets.')
            print('2. Certain types of pets.')
            print('3. Search for a Pet.')
            print('4. Sort list based on pet name.')
            print('5. Sort list based on pet color.')
            print('6. Exit the program.')

            enter1 = float(input('Enter your choice: '))
            if enter1 == 1:
                # Print only the names of all the pets
                print('Here are the names of pets:')
                print(name_list)
                print('')
            elif enter1 == 2:
                enter2 = input('What kind of pet would you like to see (dog/cat/fish/bird): ')
                print(animal_type(enter2))
            elif enter1 == 3:
                enter3 = input('Search pet name: ')
                print(search(enter3))
                print('')
            elif enter1 == 4:
                insertion_sort_name(your_list)
                print('Sorted list: ', your_list)
                print('')
            elif enter1 == 5:
                insertion_sort_color(your_list)
                print('Sorted list: ', your_list)
                print('')
            elif enter1 == 6:
                exit()
            else:
                print('Invalid value.')
    except IOError:
        print('An error occurred trying to read')
        print('Non-numeric data is allowed.')
        print('Your Pet Finder menu: ')
        print('===========================')
        print('1. Display the names of all the pets.')
        print('2. Certain types of pets.')
        print('3. Search for a Pet.')
        print('4. Sort list based on pet name.')
        print('5. Sort list based on pet color.')
        print('6. Exit the program.')
        enter1 = float(input('Enter your choice: '))
    except ValueError:
        print('Non-numeric data is allowed.')
        print('Your Pet Finder menu: ')
        print('===========================')
        print('1. Display the names of all the pets.')
        print('2. Certain types of pets.')
        print('3. Search for a Pet.')
        print('4. Sort list based on pet name.')
        print('5. Sort list based on pet color.')
        print('6. Exit the program.')
        enter1 = float(input('Enter your choice: '))
    except Exception as err:
        print(err)
        print('Non-numeric data is allowed.')
        print('Your Pet Finder menu: ')
        print('===========================')
        print('1. Display the names of all the pets.')
        print('2. Certain types of pets.')
        print('3. Search for a Pet.')
        print('4. Sort list based on pet name.')
        print('5. Sort list based on pet color.')
        print('6. Exit the program.')
        enter1 = float(input('Enter your choice: '))
Exemplo n.º 15
0
LastEditors: Howie Hong(希理)
Description: 
Date: 2019-05-05 16:33:18
LastEditTime: 2019-05-05 17:06:08
'''
import sys
path = sys.path[0]
sys.path.append(path)
import dog

print('Creating two dogs\n')

print('Creating the first dog.')
name = input('What is the name of the first dog? ')
breed = input('What is the breed of the first dog? ')
dog_a = dog.Dog(name,breed)
print()

print('Creating the second dog.')
name = input('What is the name of the second dog? ')
breed = input('What is the breed of the second dog? ')
dog_b = dog.Dog(name,breed)
print()

print('Here is the information for each dag\n')

print('The first dog:')
print(str(dog_a))

print('The second dog:')
print(str(dog_b))
Exemplo n.º 16
0
import dog

import pack

my_dog = dog.Dog("Buck")

my_pack = pack.Pack(get_leader_name)
Exemplo n.º 17
0
import dog

my_dog = dog.Dog("Rex", "SuperDog")
my_dog.bark()

my_other_dog = dog.Dog("Annie", "SuperDog")
print(my_other_dog.name)

my_other_dog = dog.Dog("Tom", "golden")
print(my_other_dog.bark())

my_other_dog = dog.Dog("Annie", "poodle")
print(my_other_dog.sit())

my_other_dog = dog.Dog("Annie", "Finland")
print(my_other_dog.roll_over())
Exemplo n.º 18
0
import dog

my_dog1 = dog.Dog("Rex", "SuperDog")
my_dog2 = dog.Dog("Annie", "LazyDog")
my_dog3 = dog.Dog("Castor", "FunDog")

my_dog1.bark()
my_dog2.sit()
my_dog3.roll()
Exemplo n.º 19
0
import dog  # we need to specify exactly what we want

my_dog = dog.Dog("Rex", "SuperDog")
my_dog.bark()

my_other_dog = dog.Dog("Annie", "SuperDog")
print(my_other_dog.name)

my_other_dogs = dog.Dog("Bear", "Cat")
my_dog.bark()

my_other_doggie = dog.Dog("MArk", "poodle")
my_other_doggie.sit()

my_other_doggies = dog.Dog("MAx", "Wolf")
my_other_doggies.rollover()
Exemplo n.º 20
0
import dog

my_dog = dog.Dog("Rex", "SuperDog")
#print(my_dog)
#print(my_dog.name)
#print(my_dog.breed)
#my_dog.bark()

#my_other_dog = dog.Dog("Annie", "SuperDog")
#print(my_other_dog.name)
sally_dog = dog.Dog("Sally", "Tibetan Mastiff")
harrison_dog = dog.Dog("Harrison", "English Bulldog")
luke_dog = dog.Dog("Luke", "Chihuahua")

sally_dog.bark()
harrison_dog.sit()
luke_dog.roll()
Exemplo n.º 21
0
import dog

my_dog = dog.Dog("Rex", "SuperDog")
my_other_dog = dog.Dog("Annie", "bulldog")
my_other_other_dog = dog.Dog("Tomura", "husky")
my_dog.bark()
my_dog.Roll()
my_other_other_dog.Sit()

Exemplo n.º 22
0
import dog

my_dog = dog.Dog("Rex", "SuperDog")
my_dog.bark()

annie = dog.Dog("Annie", "SuperDog")
samuel = dog.Dog("Samuel", "SuperDog")

samuel.sit()
annie.roll()
Exemplo n.º 23
0
import dog

my_other_dog = dog.Dog("Annie", "SuperDog")
print(my_other_dog.name)
Exemplo n.º 24
0
import dog

my_dog = dog.Dog("Rex", "SuperDog")
print(my_dog.name)
my_dog.bark()

my_other_dog = dog.Dog("Annie", "SuperDog")
print(my_other_dog.name)
my_other_dog.sit()

my_third_dog = dog.Dog("Spike", "Just a normal dog")
print(my_third_dog.name)
my_third_dog.roll_over()
Exemplo n.º 25
0
import dog

myDog = dog.Dog("rex", "superdog")

myDog.bark()
mySecondDog = dog.Dog("sebastian", "rollingdog")
myThirdDog = dog.Dog("jennifer", "sittingdog")
myFourthDog = dog.Dog("ophelia", "runningdog")

mySecondDog.rollover()  #sebastian will roll over
myThirdDog.sit()  #jennifer will sit
myFourthDog.run()  #ophelia will run

print(" ")

dog.greeting = "woah!"
myDog.bark()
mySecondDog.bark()
myThirdDog.bark()
myFourthDog.bark()
Exemplo n.º 26
0
import dog

my_dog = dog.Dog("Rex", "SuperDog")
#my_dog.breed = "SuperDog"
my_dog.bark()
my_other_dog = dog.Dog("Annie", "SuperDog")
my_other_dog2 = dog.Dog("boy", "WackyDog")
my_other_dog3 = dog.Dog("boyoy", "PartyDog")
print(my_other_dog.name)
my_other_dog.sit()
print(my_other_dog2.name)
my_other_dog2.rollover()
print(my_other_dog3.name)
my_other_dog3.run()

dog.greeting = "Woah"
my_dog.bark()
my_other_dog.bark()
my_other_dog2.bark()
my_other_dog3.bark()
Exemplo n.º 27
0
import dog

my_dog = dog.Dog("Piper")
my_dog.sit()
my_dog.lay()
my_dog.roll()
my_dog.catch()
my_dog.soccer()
my_dog.print_trick_list()
Exemplo n.º 28
0
import dog

my_dog = dog.Dog("Rex", "SuperDog")
my_other_dog = dog.Dog("Annie", "SuperDog")
my_other_dog1 = dog.Dog("Jackpot", "Jack Russell Terrier")

my_dog.bark()
my_other_dog1.sit()
my_other_dog.roll_over()
Exemplo n.º 29
0
import dog
my_dog = dog.Dog("Mochi", "Boston Terrier", "*scratchy bark*")
my_dog.bark()
Exemplo n.º 30
0
import dog

my_dog = dog.Dog("CJ", "Puppy")
print(my_dog)
print(my_dog.name)

my_other_dog = dog.Dog("Annie", "SuperDog")
print(my_other_dog.name)
""" Adding Properties """
# Adding the "breed" property on the fly
my_dog.breed = "SuperDog"
# will print "SuperDog"
print(my_dog.breed)

my_dog.bark()