Beispiel #1
0
def main():
    while True:
        choice = get_user_choice(main_menu)
        if choice == 1:
            pet_name = input("What would you like to name your pet?\n")
            print("Please choose the type of pet:")
            type_choice = get_user_choice(adoption_menu)
            if type_choice == 1:
                pets.append(Pet(pet_name))
            elif type_choice == 2:
                pets.append(CuddlyPet(pet_name))
            pets.append(Pet(pet_name))
            print("You now hae %s pets" % len(pets))
        if choice == 2:
            for pet in pets:
                pet.get_love()
        if choice == 3:
            for pet in pets:
                pet.eat_food()
        if choice == 4:
            for pet in pets:
                print(pet)
        if choice == 5:
            for pet in pets:
                pet.get_toy(Toy())
        if choice == 6:
            for pet in pets:
                pet.be_alive()

        if choice == 7:
            print("Thanks for playing!!!")
            break
Beispiel #2
0
 def test___str__(self, mock_get_complex_object, mock_get_age,
                  mock_get_species):
     mock_get_complex_object.return_value = Random()
     mock_get_age.return_value = 12
     mock_get_species.return_value = 'Dog'
     pet_instance = Pet('Clifford', 'Dog', 12)
     self.assertEqual(pet_instance.__str__(),
                      'Random Clifford is a dog aged 12')
def test_pet_has_details():
    d1 = {"age": 3, "sex": "female"}
    p1 = Pet(**d1)
    assert p1.name == "molly"
    assert p1.species == "dog"
    d2 = {"name": "frank", "species": "spider"}
    p2 = Pet(**d2)
    assert p2.name == "frank"
    assert p2.species == "spider"
Beispiel #4
0
    def status(egg):
        """
        This is responsible for allowing the player
        to check the status of their Pokemon. It checks the time elapsed since
        the last time the player has checked and updates the stats accordingly.
        """

        egg.speak()
        egg.decrease_health()
        egg.decrease_happiness()
        egg.increase_hunger()
        Pet.display_stats(egg)
    def __init__(self, has_shots=False, **kargs):
        """subclass constructor

        Args:
            has_shots (bool): false
            **kargs: arbitrary argument dictionary
        Attributes:
            has_shots (bool): set to false
        """

        self.has_shots = has_shots
        Pet.__init__(self, **kargs)
Beispiel #6
0
    def __init__(self, has_shots=False, **kwargs):
        """ Constructor for Dog class

        Args:
            has_shots(bool): def to False
            **kargs(arb): arb argument dict

        Attibutes
            has_shots(bool): True or def. to False

        """
        self.has_shots = has_shots
        Pet.__init__(self, **kwargs)
Beispiel #7
0
 def __init__(self,
              pict_s=STICH_IMAGES.STICH_HELLO,
              pict_die=STICH_IMAGES.STICH_DIE,
              pict_funny=STICH_IMAGES.STICH_FUNNY,
              pict_eat=STICH_IMAGES.STICH_EAT,
              pict_left=STICH_IMAGES.STICH_LEFT,
              pict_right=STICH_IMAGES.STICH_RIGHT,
              pict_sleep=STICH_IMAGES.STICH_SLEEP,
              pict_angry=STICH_IMAGES.STICH_ANGRY,
              pict_upset=STICH_IMAGES.STICH_UPSET,
              pict_happy=STICH_IMAGES.STICH_HAPPY):
     Pet.__init__(self, 5, 20, 20, 100, 0.5, 500, pict_s, pict_die,
                  pict_funny, pict_eat, pict_left, pict_right, pict_sleep,
                  pict_angry, pict_upset, pict_happy)
Beispiel #8
0
 def __init__(self,
              pict_s=FOX_IMAGES.FOX_HELLO,
              pict_die=FOX_IMAGES.FOX_DIE,
              pict_funny=FOX_IMAGES.FOX_FUNNY,
              pict_eat=FOX_IMAGES.FOX_EAT,
              pict_left=FOX_IMAGES.FOX_LEFT,
              pict_right=FOX_IMAGES.FOX_RIGHT,
              pict_sleep=FOX_IMAGES.FOX_SLEEP,
              pict_angry=FOX_IMAGES.FOX_ANGRY,
              pict_upset=FOX_IMAGES.FOX_UPSET,
              pict_happy=FOX_IMAGES.FOX_HAPPY):
     Pet.__init__(self, 5, 10, 30, 30, 1, 50, pict_s, pict_die, pict_funny,
                  pict_eat, pict_left, pict_right, pict_sleep, pict_angry,
                  pict_upset, pict_happy)
Beispiel #9
0
def main():
    while True:
        choice = get_user_choice(main_menu)
        #allowing user to adopt a pet
        if choice == 1:
            pet_name = input("What would you like to name your pet? ")
            print("Please choose the type of pet:")
            type_choice = get_user_choice(adoption_menu)
            if type_choice == 1:
                pets.append(Pet(pet_name))
            elif type_choice == 2:
                pets.append(CuddlyPet(pet_name))
            print("You now have %d pets" % len(pets))
        if choice == 2:
            for pet in pets:
                pet.get_love()
        if choice == 3:
            for pet in pets:
                pet.eat_food()
        #View pet status
        if choice == 4:
            for pet in pets:
                print(pet)
        if choice == 5:
            for pet in pets:
                pet.get_toy(Toy())
        if choice == 6:
            # Pet levels naturally lower.
            for pet in pets:
                pet.be_alive()
Beispiel #10
0
def test_pet_has_age_and_sex():
    d = {"age": 7, "sex": "male"}
    p = Pet(**d)
    assert p.name == "molly"
    assert p.species == "dog"
    assert p.age == 7
    assert p.sex == "male"
Beispiel #11
0
def test_updatePet():
    pet = Pet(201, 202, 'sparrow', 'available')
    put_Res = update_pet_name_and_status(pet)
    print(put_Res.status_code)
    print(put_Res.json())
    assert put_Res.json()['name'] == 'sparrow'
    assert put_Res.json()['status'] == 'available'
Beispiel #12
0
def main():
    while True:
        clear()
        choice = get_user_choice(main_menu)
        if choice == 1:
            pet_name = input("What would you like to name your pet? ")
            print("Please choose the type of pet:")
            type_choice = get_user_choice(adoption_menu)
            if type_choice == 1:
                pets.append(Pet(pet_name))
            elif type_choice == 2:
                pets.append(CuddlyPet(pet_name))
            print("You now have %d pets" % len(pets))
        if choice == 2:
            for pet in pets:
                pet.get_love()
        if choice == 3:
            for pet in pets:
                pet.eat_food()
        if choice == 4:
            for pet in pets:
                pet.get_toy(Toy())
        if choice == 5:
            for pet in pets:
                print(pet)
                input("")
        if choice == 6:
            for pet in pets:
                pet.be_alive()
        if choice == 7:
            clear()
            print("Thanks for adopting and taking care of your pet.")
            return False
Beispiel #13
0
    def __init__(self):
        self.pos: Tuple = 150, get_canvas_height() // 2
        self.delta: Tuple = 0, 0

        self.pet = Pet(*self.pos, self)
        gfw.world.add(gfw.layer.player, self.pet)

        self.state = None
        self.set_state(RunningState)

        self.bb_idx = 0
        self.score = 0
        # each meso's score
        self.ea_score = 0
        self.invincible = 0

        self.life_gauge = LifeGauge(10, 10)
        gfw.world.add(gfw.layer.ui, self.life_gauge)
def test_exercise():
    os.chdir('src')

    from pet import Pet
    from person import Person
    lucky = Pet("Lucky", "collie")
    james = Person("James", lucky)

    assert str(james) == "James, has a friend called Lucky (collie)"
Beispiel #15
0
    def on_receive(j):
        window.requestAnimationFrame(step)
        for pid, owner, name, dna in j:
            if pid not in pets_by_id:
                pet = Pet()
                pet.pid = pid
                pet.owner = owner if owner else 0
                pet.name = name if name else "boss"
                pets_by_id[pet.pid] = pet
                pets.append(pet)
            else:
                pet = pets_by_id[pid]

            pet.from_json(dna)
            pet.make_balls()
Beispiel #16
0
def play():
    animals = []

    option = ""
    base_prompt = """
    Quit
    Adopt <petname_with_no_spaces_please>
    Greet <petname>
    Teach <petname> <word>
    Feed <petname>

    Choice: """
    feedback = ""
    while True:
        action = input(feedback + "\n" + base_prompt)
        feedback = ""
        words = action.split()
        if len(words) > 0:
            command = words[0]
        else:
            command = None
        if command == "Quit":
            print("Exiting...")
            return
        elif command == "Adopt" and len(words) > 1:
            if whichone(animals, words[1]):
                feedback += "You already have a pet with that name\n"
            else:
                animals.append(Pet(words[1]))
        elif command == "Greet" and len(words) > 1:
            pet = whichone(animals, words[1])
            if not pet:
                feedback += "I didn't recognize that pet name. Please try again.\n"
                print()
            else:
                pet.hi()
        elif command == "Teach" and len(words) > 2:
            pet = whichone(animals, words[1])
            if not pet:
                feedback += "I didn't recognize that pet name. Please try again."
            else:
                pet.teach(words[2])
        elif command == "Feed" and len(words) > 1:
            pet = whichone(animals, words[1])
            if not pet:
                feedback += "I didn't recognize that pet name. Please try again."
            else:
                pet.feed()
        else:
            feedback += "I didn't understand that. Please try again."

        for pet in animals:
            pet.clock_tick()
            feedback += "\n" + pet.__str__()
def load_petData():
    with open(pet_file, 'r', newline='') as csvfile:
        reader = list(csv.reader(csvfile))
        #skip first row because of labels
        first = True
        for row in reader:
            if first:
                first = False
            else:
                list_pet.append(
                    Pet(row[0], row[1], row[2], row[3], row[4], row[5], row[6],
                        row[7], row[8], row[9], row[10]))
Beispiel #18
0
def enter():
    global cookie, stage, pet, game_timer, gameinfo, hp_time
    game_timer = get_time()
    hp_time = get_time()
    cookie = Cookie()
    gameinfo = GameInfo()
    stage = Stage()
    pet = Pet()
    game_world.objects = [[], [], [], []]
    game_world.add_object(stage, 0)
    game_world.add_object(cookie, 1)
    game_world.add_object(pet, 2)
    game_world.add_object(gameinfo, 3)
Beispiel #19
0
def main():
    while True:
        choice = get_user_choice(main_menu)
        if choice == 1:
            pet_name = input(
                u"\n\u001b[32;1m Please enter the name of your new pet: \u001b[0m\n"
            )
            print(
                u"\u001b[35;1m\n What type of pet would you like to adopt? \u001b[0m\n"
            )
            type_choice = get_user_choice(adoption_menu)
            if type_choice == 1:
                pets.append(Pet(pet_name))
            elif type_choice == 2:
                pets.append(PlayfulPet(pet_name))
                print(u"\n\u001b[35;1m Extra playful!! \u001b[0m\n")
            print("You now have %d new pet(s) \n" % len(pets))
        if choice == 2:
            for pet in pets:
                pet.get_love()
            print(u"\u001b[32;1m This is fun! Let's play all day\u001b[0m")
        if choice == 3:
            print(
                u"\n\u001b[32;1m What kind of treat would you like to give your pet? \u001b[0m\n"
            )
            for pet in pets:
                type_treat = get_pet_treat(treat_list)
                my_treat = treat_list[type_treat]
                print(my_treat.message)
                results = my_treat.give_treat()
                pet.happiness += results[1]
                pet.hunger -= results[0]
        if choice == 4:
            for pet in pets:
                pet.eat_food()
            print(u"\u001b[32;1m YUM! That hit the spot! \u001b[0m")
        if choice == 5:
            for pet in pets:
                pet.nap_time()
            print(u"\u001b[32;1m Nap time!...I'm sleepy. \u001b[0m")
        if choice == 6:
            for pet in pets:
                print(pet)
        if choice == 7:
            for pet in pets:
                pet.get_toy(Toy())
        if choice == 8:
            for pet in pets:
                pet.life()
        if choice == 9:
            exit(print(u"\u001b[42m Please, come back soon! \u001b[0m\n"))
Beispiel #20
0
def main():

    again = 'y'

    while again.lower() == 'y':
        pet_name = input('Pet name: ')
        pet_type = input('Pet type: ')
        pet_age = input('Pet age: ')

        the_pet = Pet(pet_name, pet_type, pet_age)

        print()
        print(the_pet)

        again = input('Again? (y/n): ')
Beispiel #21
0
def main():
    print("\033c")
    while True:
        choice = get_user_choice(main_menu)

        if choice == 1:
            pet_name = input("What would you like to name your pet? ")
            print("Please choose the type of pet: ")
            type_choice = get_user_choice(adoption_menu)
            if type_choice == 1:
                pets.append(Pet(pet_name))
            elif type_choice == 2:
                pets.append(CuddlyPet(pet_name))
            print("You now have %d pets" % len(pets))
            transition()

        if choice == 2:
            for pet in pets:
                pet.get_love()
                print("All your pets are now a little happier!\n")
            transition()

        if choice == 3:
            for pet in pets:
                pet.eat_food()
                print("All your pets are now a little more full!\n")
            transition()

        if choice == 4:
            if pets != []:
                for pet in pets:
                    print(pet)
            else:
                print("You don't have any pets right now.\n")
            transition()

        if choice == 5:
            for pet in pets:
                pet.get_toy(Toy())
                print("You gave all your pets a toy!\n")
            transition()

        if choice == 6:
            for pet in pets:
                pet.be_alive()
            transition()
def main():  #copied and pasted
    while True:
        choice = get_user_choice(main_menu)
        if choice == 1:
            pet_name = input("What would you like to name your pet? ")
            print("Please choose the type of pet:")
            type_choice = get_user_choice(adoption_menu)
            if type_choice == 1:
                pets.append(
                    Pet(pet_name)
                )  #still not sure why error ***had incorrect vlaues for methods FIXED
            elif type_choice == 2:
                pets.append(CuddlyPet(pet_name))
            print("You now have %d pets" % len(pets))

        if choice == 4:
            for pet in pets:
                print(pet)
Beispiel #23
0
def main():
    main = Menu("Please choose an option:", main_menu)
    type = Menu("Please choose the type of pet:", adoption_menu)
    treat = Menu("Please choose the type of treat:", treat_menu)
    while True:
        choice = main.get_choice()
        if choice == 1:
            pet_name = input("What would you like to name your pet? ")
            type_choice = type.get_user_choice()
            if type_choice == 1:
                pets.append(Pet(pet_name))
            elif type_choice == 2:
                pets.append(CuddlyPet(pet_name))
            print("You now have %d pets" % len(pets))
        if choice == 2:
            for pet in pets:
                pet.get_love()
            print("Pets have been loved!")
        if choice == 3:
            for pet in pets:
                pet.eat_food()
            print("Pets have been fed!")
        if choice == 4:
            for pet in pets:
                print(pet)
        if choice == 5:
            for pet in pets:
                pet.get_toy(Toy())
            print("Pets got a toy!")
        if choice == 6:
            treat_choice = treat.get_user_choice()
            if treat_choice == 1:
                treat_type = ColdPizza()
            if treat_choice == 2:
                treat_type = Bacon()
            if treat_choice == 3:
                treat_type = VeganSnack
            for pet in pets:
                pet.get_treat(treat_type)
            print("Pets got a treat!")
        if choice == 7:
            for pet in pets:
                pet.be_alive()
            print("Pets did nothing!")
Beispiel #24
0
def main():
    app = Menu("Please choose an option", main_menu)
    types = Menu("Please choose a type of pet", adoption_menu)
    treats = Menu("please choose a type of treat", treat_menu)
    while True:
        choice = app.get_user_choice()
        if choice == 1:
            pet_name = input("What would you like the pet name to be?")
            type_choice = types.get_user_choice()
            if type_choice == 1:
                pets.append(Pet(pet_name))
            elif type_choice == 2:
                pets.append(CuddlyPet(pet_name))
            num_pets = len(pets)
            print(f"You now have {num_pets} pets")
        elif choice == 2:
            for pet in pets:
                pet.get_love()
        elif choice == 3:
            for pet in pets:
                pet.eat_food()
        elif choice == 4:
            for pet in pets:
                print(pet)
        elif choice == 5:
            for pet in pets:
                pet.get_toy(Toy())
        elif choice == 6:
            for pet in pets:
                pet.be_alive()
        elif choice == 7:
            print("Please choose your type of treat:")
            treat_choice = treats.get_user_choice
            if treat_choice == 1:
                for pet in pets:
                    pet.eat_treat(ColdPizza())
            elif treat_choice == 2:
                for pet in pets:
                    pet.eat_treat(Bacon())
            elif treat_choice == 3:
                for pet in pets:
                    pet.eat_treat(VeganSnack())
Beispiel #25
0
 def __init__(self,
              name="unknown",
              surname="unknown",
              year=0,
              iq=0,
              pet="unknown",
              mother='unknown',
              father='unknown',
              schedule=None):
     self.__name = name
     self.__surname = surname
     self.__year = int(year)
     if 0 <= iq <= 100:
         self.__iq = iq
     self.__pet = Pet(pet)
     self.__mother = Human(mother)
     self.__father = Human(father)
     if schedule is None:
         schedule = []
     else:
         self.__schedule = list(schedule)
Beispiel #26
0
def main():
    app = Menu('Please choose an Option: ', main_menu)
    types = Menu('Please choose a Pet Option: ', adoption_menu)
    treats = Menu('Please choose a Treat Option: ', menu_menu)
    while True:
        choice = app.get_choice()
        if choice == 1:
            pet_name = input('What do you want to name your pet?')
            type_choice = types.get_choice()
            if (type_choice == 1):
                pets.append(Pet(pet_name))
            elif (type_choice == 2):
                pets.append(CuddlyPet(pet_name))
            print(f'\n\nYou now have {len(pets)} pets')
        elif choice == 2:
            for pet in pets: pet.get_love()
        elif choice == 3:
            treat_choice = treats.get_choice()
            food_to_feed = 0
            if(treat_choice == 1):
                food_to_feed = ColdPizza()
            elif(treat_choice == 2):
                food_to_feed = Bacon()
            elif(treat_choice == 3):
                food_to_feed = VeganSnack()
            for pet in pets: pet.eat_food(food_to_feed)
        elif choice == 4:
            for pet in pets:
                print(pet)
        elif choice == 5:
            for pet in pets:
                pet.get_toy(Toy())
        elif choice == 6:
            for pet in pets: 
                pet.be_alive()
                print(pet)
Beispiel #27
0
def main():
    pet = Pet()

    print(pet)
Beispiel #28
0
 def test_lower(self):
     self.assertEqual(Pet.lower(s='Dog'), 'dog')
Beispiel #29
0
 def test_get_name(self):
     pet_instance = Pet('Clifford', 'Dog', 12)
     self.assertEqual(pet_instance.get_name(), 'Clifford')
Beispiel #30
0
import sys

sys.path.append("./pytests/classes/nestedFolder")
from pet import Pet

p = Pet("CoolGuy", "Llama")

print p.name
print p.__dict__["name"]
print p.getName()

from specific_pets import Dog, Cat

d = Dog("Fido", False)
print d.name
print d.__dict__["name"]
print d.getName()
print d.chasesCats()

print isinstance(p, Pet)
print isinstance(p, Dog)
print isinstance(d, Pet)
print isinstance(d, Dog)
print isinstance(d, Cat)
from pet import Pet
from dog import Dog

# Pet
myPet = Pet()

myPet.petName = input()
myPet.petAge = int(input())
myPet.printInfo()
# Dog
myDog = Dog()

myDog.petName = input()
myDog.petAge = input()
myDog.dogBreed = input()
myDog.printInfo()
from pet import Pet

pets = list()  #an empty list that will store all the pets in the shops

#initialize and describe Spot the Dog.
spot = Pet('Spot')
spot.set_animal('dog')
spot.set_description('Short legged, white fur with a single black spot')
''' spot.set_noise('Woof!') '''
pets.append(spot)

#initialize and describe Shadow the Cat.
shadow = Pet('Shadow')
shadow.set_animal('cat')
shadow.set_description(
    'Shy, with all dark fur. She likes to hide behind furniture.')
''' shadow.set_noise('Meow!')  '''
pets.append(shadow)
''' Add your own pet(s) here '''

#Customer Interaction with the Pets
print('Welcome to My Pet Shop!')

current_pet = pets[0]

while True:
    print('\n')
    print('Choose the pet that you would like to meet.')

    for index, pet_name in enumerate(pets):  #prints a list of pets
        print(index, pet_name.get_name())
Beispiel #33
0
	def __init__(self, species):
		Pet.__init__(self, species)
Beispiel #34
0
@decrators.login_required
def show_data():
  print 'secret picture'


def f(a, b, c, d=0):
  print a, b, c, d

def wrapper_1(num, *args, **kwargs):
  print args
  print kwargs
  return f(num, *args, **kwargs)


pet = Pet(name='snoopy', age=3)

@decrators.mock_patch_object(pet, 'wakeup')
@decrators.mock_patch_object(pet, 'sleep')
def testPet(mock_sleep, mock_wakeup):
  mock_sleep.return_value = 'hehe'
  mock_wakeup.return_value = 'oh'
  print pet.sleep()
  print pet.wakeup()


@decrators.accepts(float, (int, float, int))
def func(arg1, arg2, arg3):
  return arg1 * arg2

Beispiel #35
0
	def __init__(self, species, price):
		Pet.__init__(self, species)
		self.price = 4
Beispiel #36
0
 def __init__(self, name, chases_cats):
     Pet.__init__(self, name, "Dog")
     self.chases_cats = chases_cats
Beispiel #37
0
 def __init__(self, name, hates_dogs):
     Pet.__init__(self, name, "Cat")
     self.hates_dogs = hates_dogs