Exemplo n.º 1
0
def main():
	Dog1 = Dog()
	Dog1.dogInfo()

	print("dog legs = " + str(Dog1.legs))
	Dog1.legs = 6
	print("dog legs = " + str(Dog1.legs))
Exemplo n.º 2
0
    def __initializeZoo():
        animals = []

        animals.append(Hippo("hippo1"))
        animals.append(Hippo("hippo2"))

        animals.append(Rhino("rhino1"))
        animals.append(Rhino("rhino2"))

        animals.append(Elephant("elephant1"))
        animals.append(Elephant("elephant2"))

        animals.append(Cat("cat1"))
        animals.append(Cat("cat2"))

        animals.append(Tiger("tiger1"))
        animals.append(Tiger("tiger2"))

        animals.append(Lion("lion1"))
        animals.append(Lion("lion2"))

        animals.append(Wolf("wolf1", WolfNoise()))
        animals.append(Wolf("wolf2", WolfNoise()))

        animals.append(Dog("dog1", DogNoise()))
        animals.append(Dog("dog2", DogNoise()))

        return animals
    def Execute(self,gui,dMaps,house,ID, Cselection):

        gui.ClearFrame()
        gui.CreateCanvas()

        self.DisplayMap(gui)

        house.FillHouse(gui,2,ID)

        if Cselection == 1:
            cat = Cat(gui,Info.name,Textures.TextureDict["cat"],self.ExitX,self.ExitY,house.List[ID].item)

        elif Cselection == 2:
            cat = Cat(gui,Info.name,Textures.TextureDict["snowball"],self.ExitX,self.ExitY,house.List[ID].item)

        elif Cselection == 3:
            cat = Cat(gui,Info.name,Textures.TextureDict["tom"],self.ExitX,self.ExitY,house.List[ID].item)

        elif Cselection == 4:
            cat = Cat(gui,Info.name,Textures.TextureDict["scratchy"],self.ExitX,self.ExitY,house.List[ID].item)

        elif Cselection == 5:
            cat = Cat(gui,Info.name,Textures.TextureDict["pink"],self.ExitX,self.ExitY,house.List[ID].item)


        dog = Dog(int(Info.difficulty),gui,Textures.TextureDict["dog"],cat)

        gui.root.bind("<z>",lambda event: self.preChange(cat.catID,gui,dMaps,house,dog, Cselection)) # changes to ouside map, <Return> is "enter" key

        dog.movement(gui)
Exemplo n.º 4
0
def test_book_dog(monkeypatch, company_with_enclosures_and_dogs):
    dog1 = Dog("Pongo", "Roger", 3, "Dalmation", "A lady name \'de vil\' may attempt to check this dog out - do not allow this!")
    dog2 = Dog("Lady", "Jim Dear and Darling", 2, "Cocker Spaniel", "Often visited by a stray")

    monkeypatch.setattr(Enclosure, "add_occupant", add_occupant_temp)
    monkeypatch.setattr(Enclosure, "check_suitability", lambda self, dog: True)
    company_with_enclosures_and_dogs.book_dog(dog1)
    company_with_enclosures_and_dogs.book_dog(dog2)
    assert company_with_enclosures_and_dogs.spaces_left() == 15
Exemplo n.º 5
0
def company_with_enclosures_and_dogs(monkeypatch):
    monkeypatch.setattr(Kennel_Company, "load_enclosures", load_enclosures_stub)
    company = Kennel_Company()

    # Manual adding of dog to help remove test
    company.enclosures[0].occupants.append( Dog("Brian", "Peter Griffin", 9, "Labrador", "Is able to talk!"))
    return company
Exemplo n.º 6
0
def main():
  global playerHP, enemyHP
  play = True
  while play:
    team = [DaFish("LeFishe"), Gibson("Gibson"), Dog("Cat")]
    enemy = DaFish("CEO of FishCarp Inc")
    prompt = True
    while prompt = int(input("Choose Nomi: [1) DaFish, 2) Gibson, 3) Dog]"))
    if response == 1:
      chooseNomi = team[0]
      prompt = False
    elif response == 2:
      chooseNomi = team[1]
      prompt = False
    elif response == 3:
      chooseNomi = team[2]
      prompt = False
    else:
      print("Invalid Input! Enter a number 1-3.")

  fight = True
  while fight:
    moveNum = rndom randint(0, 3)
    fight = attackAction(chosenNomi, enemy, enemy.moveSet[moveNum])

  prompt = True
  while prompt:
    response = Input ("Fight another battle? (y/n)")
    if response.lower == "y":
      play = True
    elif response.lower =="n":
      play = False
    else:
      print("Please enter a valid input. (y/n)")
  print("----------------------------------")
Exemplo n.º 7
0
def user_fav_page():
    if not current_user.is_authenticated:
        return redirect(url_for('login'))
    # page = request.args.get('page', 1, type=int)
    user = User.query.filter_by(email=current_user.email).first_or_404()
    # grab the first user or return a 404 page
    fav_dogs_ids = [
        dog.dog_id
        for dog in User.query.filter_by(id=current_user.id).first().favs
    ]
    fav_dogs = Dogs.query.filter(Dogs.dog_id.in_(fav_dogs_ids)).all()
    # Convert database info to Dog objects
    dogs = [
        Dog(id=fav_dog.dog_id,
            org_id=None,
            breed1=None,
            breed2=None,
            age=fav_dog.dog_age,
            gender=fav_dog.dog_gender,
            spayed=None,
            name=fav_dog.dog_name,
            photo_thumbnail=fav_dog.dog_pic,
            email=None,
            phone=None,
            city=None,
            photos=None,
            environment=None,
            description=None,
            address=None) for fav_dog in fav_dogs
    ]

    return render_template('my_dogs.html',
                           dogs=dogs,
                           user=user,
                           fav_dogs=fav_dogs_ids)
Exemplo n.º 8
0
def loop():
    dogs = []
    # First dog
    firstDog = Dog("Doggo", "Corgi")
    dogs.append(firstDog)
    done = False
    while not done:
        acts = []
        printOptions()
        action = parseInput()
        if action == 0:
            done = True
        else:
            printTargetDogs(dogs)
            dog = parseInput()
            if action == 1:
                dogs[dog].rapsuttaa()
            elif action == 2:
                dogs[dog].walking()
            elif action == 3:
                dogs[dog].feed()
        for d in dogs:
            d.update()
            acts.append([d, d.act()])
        printActs(acts)
Exemplo n.º 9
0
    def Execute(self, gui, dMaps, house, ID):

        gui.ClearFrame()
        gui.CreateCanvas()

        self.DisplayMap(gui)

        house.FillHouse(gui, 2, ID)

        cat = Cat(gui, Info.name, Textures.TextureDict["cat"], self.ExitX, self.ExitY, house.List[ID].item)
        dog = Dog(int(Info.difficulty), gui, Textures.TextureDict["dog"], cat)

        gui.root.bind(
            "<z>", lambda event: self.preChange(cat.catID, gui, dMaps, house, dog)
        )  # changes to ouside map, <Return> is "enter" key

        dog.movement(gui)
Exemplo n.º 10
0
def do():
    pets = [Dog('狗狗', '小黑'), Cat('猫猫', '小花')]
    for p in pets:
        # 继承
        p.eat('骨头')
        # 多态
        p.call()
        print("******")
Exemplo n.º 11
0
def main():
	print "We have added more to our Dog and Animal class"

	dog1 = Dog("Spot","BullDog")
	animal1 = Animal("Mickey", "Mouse")

	animal1.getName()
	animal1.getType()

	dog1.getName()
	dog1.getBreed()

	dog1.setName("Pluto")
	dog1.getName()
Exemplo n.º 12
0
    def __init__(self, persons, dogs):
        self.num_Person = persons
        for i in range(0, persons):
            p = Person()
            self.persons.append(p)

        self.num_Dog = dogs
        for i in range(0, dogs):
            d = Dog()
            self.dogs.append(d)
Exemplo n.º 13
0
    def save(self):    
        
        # Declare a string named breed, store the contents of the self.breed StringVar
        # in the new string. Hint: use the .get() method. Make sure to trim whitespace in the entry widget!
        breed = self.breed.get().strip()

        # Do the same thing for a new string named name, storing self.name StringVar
        name = self.name.get().strip()

        # Do the same thing for a new string named weight, storing self.weight StringVar
        weight = self.weight.get().strip()
      
        # Do the same thing for a new string named age, storing self.age StringVar
        age = self.age.get().strip()
    

        # Create a new dog object and pass the 4 required parameters to it using the 4 variables you just created.
        # This will store the text in the widgets in the object data fields.
        storeDog = Dog(breed, name, weight, age)
                

        # Declare a new variable named notes, getting and storing the whitespace-trimmed contents of the text widget into it.
        notes = self.text.get('1.0', END).strip()
        
        # declare a new MULTILINE string named savetext, using your 4 Dog class get methods.
        # you will need to concatenate each field of the string with the + operator, and ensure
        # that each field is separated by a line feed.
        # Also, make sure that you add the notes variable at the end of your string definition
        savetext = (storeDog.getBreed() + '\n' + storeDog.getName() + '\n' + storeDog.getWeight() + '\n' + storeDog.getAge() + '\n' + notes)      

        # create a new file object that saves to .txt by default
        filenameforWriting = asksaveasfilename(defaultextension=".txt", filetypes=(("Text file", "*.txt"),("All Files", "*.*") ))
        
        # create a new object named outfile that opens our new filenameforWriting for write operations.
        outfile = open(filenameforWriting, "w")
        
        # write the contents of savetext to the file
        outfile.write(savetext)
        
        # close the file
        outfile.close()
Exemplo n.º 14
0
 def test_convert_to_dog2(self):
     self.assertEqual(
         petfinder._convert_to_dog(self.input2),
         Dog(
             45000754, 'CA1331', 'Golden Retriever', 'Husky', 'Young',
             'Male', True, 'Cooper!', None, '*****@*****.**',
             None, 'Sacramento', [], {
                 'children': None,
                 'dogs': None,
                 'cats': None
             },
             'This handsome guy is Cooper!  He is around 1.5 - 2 years old. What a friendly, loving sweet dog. He...',
             'Sacramento CA 95842'))
Exemplo n.º 15
0
 def test_convert_to_dog(self):
     self.assertEqual(
         petfinder._convert_to_dog(self.input),
         Dog(
             45000754, 'CA1331', 'Golden Retriever', 'Husky', 'Young',
             'Male', True, 'Cooper!',
             'https://dl5zpyw5k3jeb.cloudfront.net/photos/pets/45000754/4/?bust=1561690767&width=600',
             '*****@*****.**', None, 'Sacramento', [], {
                 'children': None,
                 'dogs': None,
                 'cats': None
             },
             'This handsome guy is Cooper!  He is around 1.5 - 2 years old. What a friendly, loving sweet dog. He...',
             'Sacramento CA 95842'))
Exemplo n.º 16
0
    def populate(self):

        # Canine
        self.animals.append(Dog())
        self.animals.append(Dog('Dug'))
        self.animals.append(Wolf())
        self.animals.append(Wolf('Wifi'))

        # Feline
        self.animals.append(Cat())
        self.animals.append(Cat('Catherine'))
        self.animals.append(Tiger())
        self.animals.append(Tiger('Terry'))
        self.animals.append(Lion())
        self.animals.append(Lion('Lenny'))

        # Pachyderm
        self.animals.append(Elephant())
        self.animals.append(Elephant('Esther'))
        self.animals.append(Hippo())
        self.animals.append(Hippo('Harriet'))
        self.animals.append(Rhino())
        self.animals.append(Rhino('Rose'))
Exemplo n.º 17
0
    def __init__(self):
        pygame.init()

        self.SCREEN_WIDTH = 800
        self.SCREEN_HEIGHT = 600

        self.display = pygame.display.set_mode((self.SCREEN_WIDTH, self.SCREEN_HEIGHT))
        pygame.display.set_caption("DoocHunt")
        pygame.mouse.set_visible(False)
        self.stoper = Stoper()
        self.sound = Sound()
        self.ui = UserInterface(self.display)
        self.run = True
        self.crosshair = Crosshair(self.display, self.SCREEN_WIDTH, self.SCREEN_HEIGHT)
        self.ducks = []
        self.groundImage = pygame.image.load("images/ground.png")
        self.tree = pygame.image.load("images/tree.png")
        self.duckSpriteRepository = DuckSpriteSetRepository()
        self.dogSpriteSetRepository = DogSpriteSetRepository()
        self.gameState = GameState.GAME_STARTING
        self.dog = Dog(self.display, self.stoper, self.dogSpriteSetRepository.getCollection())
        self.level = 0
        self.ammoCount = self.level + 2
        self.duckCount = self.level + 1
Exemplo n.º 18
0
def main():
    print('Criando um chachorro!!\n')
    viralata = Dog('Viralata caramelo')
    print(viralata.raca)
    viralata.latir()

    print('############################\n')

    trocaRaca(viralata)
    print('Transformação: ', viralata.raca)
    viralata.latir(lati='miauuuuuuuu2')
Exemplo n.º 19
0
def main():

    running = True

    r = Robot(tokenbot.token_bot)
    dog = Dog()
    m_flow = Msg('flw')
    m_dr = Msg('dr')  #daily route

    lst_id = r.get_f_lst_id()

    while running:
        time.sleep(r.dyn_delay)  # (0.9)

        r.get_lst_msg_bot()
        if (not r.skippy):
            if r.lst_msg_id > int(lst_id):
                m_flow.init_xtnd(r.lst_msg)

                m_flow.chk_msg_type()
                if m_flow.v_msg_fid != None:
                    m_flow.v_msg_f_pth = r.bot.get_file(
                        m_flow.v_msg_fid)['file_path']
                    m_flow.v_msg_rcgz()

                m_flow.analyze_txt_in_msg()

                r.snd_msg(m_flow.anlz_msg_cht_id, m_flow.cre_msg_txt_new)

                r.upd_f_lst_id()
                lst_id = str(r.lst_msg_id)

        m_dr.daily_route()
        if m_dr.dr_sw_warn:
            r.snd_msg(m_dr.anlz_msg_cht_id, m_dr.cre_msg_txt_new)
            m_dr.dr_sw_warn = False

        if m_flow.sw_dog_act:
            dog.dog_act()
            if dog.sw_dog_msg:
                r.snd_msg(tokenbot.dr_usr_id, dog.dog_msg)
                if m_flow.sw_dogpic:
                    r.snd_photo(tokenbot.dr_usr_id, dog.dd_jpg)
        else:
            dog.rmss_l = []

        if m_flow.sw_ssh:
            dog.ssh_act()
            m_flow.sw_ssh = False
Exemplo n.º 20
0
def _convert_to_dog(element):
    """ Convert information about one dog (returned from API call) to the object of type Dog """
    # Check if photo is available (sometimes there is no picture of a dog)
    photo_thumbnail = None
    if len(element["photos"]) > 0:
        photo_thumbnail = element["photos"][0]["large"]

    address_line1 = ""
    if element["contact"]["address"]["address1"] is not None:
        address_line1 = element["contact"]["address"]["address1"]
    address_line2 = ""
    if element["contact"]["address"]["address2"] is not None:
        address_line2 = element["contact"]["address"]["address2"]

    address = address_line1 + " " + address_line2 + " " + \
              element["contact"]["address"]["city"] + " " + element["contact"]["address"]["state"] + \
              " " + element["contact"]["address"]["postcode"]
    name = element["name"]
    if len(name) > 22:
        name = name[:21]

    return Dog(element["id"],
               element["organization_id"],
               element["breeds"]["primary"],
               element["breeds"]["secondary"],
               element["age"],
               element["gender"],
               element["attributes"]["spayed_neutered"],
               name,
               photo_thumbnail,
               element["contact"]["email"],
               element["contact"]["phone"],
               element["contact"]["address"]["city"],
               element["photos"],
               element["environment"],
               element["description"],
               address,
               )
Exemplo n.º 21
0
#!/usr/bin/env python3
# -*- coding:utf-8 -*-
from Student import Student
from Dog import Dog
from IAnimalRunning import animal_running

s1 = Student('Jack', 19)
print s1.get_name()
s1.set_age(1)
# s1.set_age(-1)

dog = Dog()
dog.run()
dog.eat()

animal_running(dog)

print isinstance([1, 2, 3], (list, tuple))
Exemplo n.º 22
0
def main():
    pets = [Dog('旺财'), Cat('凯迪'), Dog('大黄')]
    for pet in pets:
        pet.make_voice()
Exemplo n.º 23
0
from Kia import Kia
from math import *
import random
from Dog import Dog
import pandas as pd

mydog = Dog("shepard", "izzy", "large")

mydog.is_izzy()

print(mydog.name)

van1 = Kia("sedona", True, "blue", 8)

myfile = open("/Users/ironman/Desktop/python_class.txt", "r")

print(myfile.readable())

print(myfile.read())

myfile.close()

gridlist = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 12, 14], [0]]
count = 0

for letters in "wcgwcbwwecwhcwhcwncwhxwchwhw":
    print(letters)

df = pd.read_csv("/Users/ironman/Desktop/transactions.CSV")
print(df)
Exemplo n.º 24
0
from Dog import Dog
from Cat import Cat
import random
import time
import pickle

random.seed(32)
n = 100
t = 6
filename = "animal.dat"

farm = []

for i in range(n):
    r = random.randrange(0, 2)
    farm.append(Dog() if r == 0 else Cat())

day = 1
while day <= t:
    print("day {day}:".format(day=day))
    for animal in farm:
        animal.hurry()
    eat = random.sample(range(n), n * 3 // 10)
    for i in eat:
        farm[i].eat()
    day += 1
    file_animal = open(filename, 'wb')
    pickle.dump(farm, file_animal)
    time.sleep(1)

file_animal.close()
Exemplo n.º 25
0
from Dog import Dog

my_dog = Dog()

my_dog.update_age(4)
print(str(my_dog))
Exemplo n.º 26
0
 def generate_dogs(self):
     for dog_pos in self.map.dog_start_positions:
         self.all_dogs.append(Dog(self.map, dog_pos, np.array([-3.0, 3.0])))
     self.lost_sheep_pos = [np.zeros(2)] * len(self.all_dogs)
     self.lost_sheep_dists = [1] * len(self.all_dogs)
Exemplo n.º 27
0



##############################################################
# MAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIN!!!!!!!!!!!!!!!!!!!!!!!!!!
##############################################################

pygame.init()
screen = pygame.display.set_mode((Constants.WORLD_WIDTH, Constants.WORLD_HEIGHT))
done = False
clock = pygame.time.Clock()
graph = Graph()

playerPos = Vector2((Constants.WORLD_WIDTH * 0.5) - (Constants.DOGSHEEP_SIZE.x * 0.5), (Constants.WORLD_HEIGHT * 0.5) - (Constants.DOGSHEEP_SIZE.y * 0.5))
myDog = Dog(playerPos, Constants.DOG_SPEED, Constants.DOGSHEEP_SIZE)



#sheepHorizontalSeparation = Constants.WORLD_WIDTH / 11
#sheepVerticalSeparation = Constants.WORLD_HEIGHT / 11

##sheepList = [Sheep(Vector2(100, 100), Constants.SHEEP_SPEED, Constants.DOGSHEEP_SIZE)]

sheepList = []

for x in range(0, 1):
    xCoord = randint(Constants.DOGSHEEP_SIZE.x, Constants.WORLD_WIDTH - Constants.DOGSHEEP_SIZE.x)
    yCoord = randint(Constants.DOGSHEEP_SIZE.y, Constants.WORLD_HEIGHT - Constants.DOGSHEEP_SIZE.y)
    sheepPosition = Vector2(xCoord, yCoord)
    sheepList.append(Sheep(sheepPosition, Constants.SHEEP_SPEED, Constants.DOGSHEEP_SIZE))
Exemplo n.º 28
0
 def __init__(self):
     self.humans = [Human(str(i)) for i in range(2)]
     self.dogs = [Dog(str(i)) for i in range(3)]
     self.cur.add('Human' if randint(0, 1) else 'Dog')
Exemplo n.º 29
0
from Environment import Environment
from Sheep import Sheep
from Dog import Dog
import statistics
import numpy as np

if __name__ == '__main__':
    count_values = []
    for curr_ptr in range(100):

        count = 0
        env = Environment()
        sheep = Sheep()
        dogs = Dog()
        print("Sheep location {} {}".format(env.rowSheep, env.colSheep))
        print("Dog1 location {} {}".format(env.rowDog1, env.colDog1))
        print("Dog2 location {} {}".format(env.rowDog2, env.colDog2))

        diag1, diag2 = dogs.get_diagonal_for_dogs(env)
        while not (diag1[0] == env.rowDog1 and diag1[1] == env.colDog1
                   and diag2[0] == env.rowDog2 and diag2[1] == env.colDog2):
            dogs.move_to_dest([env.rowDog1, env.colDog1], diag1, env)
            dogs.move_to_dest([env.rowDog2, env.colDog2], diag2, env)

            sheep.move(env)
            count += 1
        print(
            "---------------------------------------Dogs are at the diagonal")

        while dogs.manhattan_dist([env.rowSheep, env.colSheep],
                                  [env.rowDog1, env.colDog1]) > 0:
Exemplo n.º 30
0
import calculator
from Dog import Dog

numbers = [1,3,4,5,6]

add = calculator.add(*numbers)
  
print("add:", add)
mul = calculator.mul(*numbers)
print("multiply:", mul)
bi = Dog("Bi", 2)
bi.walk()
print(bi.age)
Exemplo n.º 31
0
import learningEx
from Dog import Dog
from Circle import Circle
from Line import Line
from Cilindre import Cilindre
from HandleExceptions import HandleExceptions
from Account import Account

if __name__ == '__main__':
    result = learningEx.newFunction(3, 6)
    print(result)
    print(learningEx.dog_check("Dog Year is a wonderful movie"))
    print(learningEx.pig_latin('tree'))
    learningEx.is_prime2(19)

    dog = Dog('husky', 'Lissa', 7)

    dog.feedDog(True)
    print(dog.tale)
    print(dog.feet)
    dog.bark(5)
    dog.swing()
    dog.eat()  #this is an inherited method
    dog.who_am_i()
    print(dog)

    myCircle = Circle(30)
    print(myCircle.area)
    print(myCircle.get_circumference())

    coordinate1 = (3, 2)
Exemplo n.º 32
0
from Dog import Dog

fido = Dog("Fido")
fido.bark(3)
Dog.rollCall(-1)
rex = Dog("Rex")
Dog.rollCall(0)

# The following line results in an error:
# myDog = Dog()
Exemplo n.º 33
0
z = 52
ar.append("a")
for x in ar:
    print(x)

animals = "cuándo no está \n"
print(f'The value of pi is approximately {z:5d}.')
print(f'My hovercraft is full of {animals!r}.')
print("Hola tengo {} apples".format(z))
print(f"Hola tengo {z} apples")
print('The value of pi is approximately %6.5f.' % math.pi)

try:
    f = open('myfile.txt')
    s = f.readline()
    i = int(s.strip())
except OSError as err:
    print("OS error: {0}".format(err))
except ValueError:
    print("Could not convert data to an integer.")
except:
    print(
        f"Unexpected error: {sys.exc_info()[0]} with size {len(sys.exc_info())}"
    )
    raise
d: Animal = Dog('Bobby')
d.add_trick('Jump')
d.add_trick('Catch the ball')

print(f"{d.get_specie()}'s name is {d.name} and his tricks are {d.tricks}")
Exemplo n.º 34
0
def main():
	dog1 = Dog("Pluto", "Hound")

	print dog1.getName()

	print dog1.getBreed()