Ejemplo n.º 1
0
    def getSpeciesList(self):
        #self.currSpeciesList = [ hare.Hare(),
        #                         fox.Fox(),
        #                         cat.Cat()]
        self.currSpeciesList = [hare.Hare(), cat.Cat()]

        for s in self.currSpeciesList:
            s.preciseLoc = [
                self.menu.rect.center[0] + self.menu.rect.width,
                self.baseSurfaceRect.center[1] +
                (self.baseSurfaceRect.height / 8)
            ]
            s.facingRight = False
Ejemplo n.º 2
0
def main():

    # Create Cat.
    # This code imported the cat module, Cat class is a name in the cat module
    kitten = cat.Cat('Kitty')
    kitten.make_sound()

    # Create Bird. Can use name directly.
    penguin = Bird('Penguin')
    penguin.make_sound()

    armadillo = Armadillo('Armadillo')
    armadillo.make_sound()
Ejemplo n.º 3
0
    def __init__(self):
        # title
        pyxel.init(WINDOW_W, WINDOW_H, caption="cute cat xxx")

        # cat config
        self.CAT_ID = 0
        self.ENEMY_ID = 1

        pyxel.image(self.CAT_ID).load(0, 0, IMG_CAT_PATH)
        pyxel.image(self.ENEMY_ID).load(0, 0, IMG_ENEMY_PATH)

        self.cat = cat.Cat(self.CAT_ID, CAT_W, (WINDOW_H - CAT_H)/2, 1)
        self.balls = []
        self.enemies = []

        pyxel.run(self.update, self.draw)
Ejemplo n.º 4
0
import cat
import numpy as np


def meow(iterations):
    for i in range(0, iterations):
        yield " ".join(["meow"] * 2**i)


if __name__ == "__main__":
    # task 1
    shark = cat.Cat("shark")
    tiger = cat.Cat("tiger")
    shark.greet(tiger)
    tiger.greet(shark)

    # task 2 - list comp
    print([i * i for i in range(0, 101) if (i * i) % 2 == 0])
    # task 3 - generators
    print([i for i in meow(10)])
    # task 4 - numpy
    arr = np.random.uniform(size=(5, 5))
    arr[arr * arr > 0.1] = 42
    print(arr)
    print(arr[:, 3])
Ejemplo n.º 5
0
#abstract keyword is not supported in python hence the reason we use this trick

#I want the sub class of animal (i.e. Dog and cat) to create its own speak method or get an error if not created

import animal, dog, cat

# anim = animal.Animal()
#above throws an error to show that abstract class cannot be instantiated

#create an instance of dog
dg = dog.Dog("Bingo")

#call the speak method
dg.speak()

print()

#create an instance of cat
ct = cat.Cat("Whiskey")

#call the speak method
ct.speak()
Ejemplo n.º 6
0
 def test_forward(self):
     garfield = cat.Cat('Garfield')
     loop = asyncio.get_event_loop()
     result = loop.run_until_complete(herd(garfield, 'forward'))
     loop.close()
     self.assertTrue(result)
Ejemplo n.º 7
0
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""Работа с классом Cat в рамках задания 1.8.1 """

import cat

cats = [cat.Cat('m', 2, 'сэм'), cat.Cat('m', 2, 'барон')]
for i in cats:
    print(i.get_info())
Ejemplo n.º 8
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: '))
Ejemplo n.º 9
0
# main.py

import cat

# 2개의 cat 인스턴스 생성
romeo = cat.Cat("Romeo")
juliet = cat.Cat("Juliet")

# 로미오와 놀아준다.
romeo.speak()
romeo.drink()

# 줄리엣과 놀아준다.
juliet.speak()
juliet.drink()
Ejemplo n.º 10
0
"""
import sys
import pygame
from pygame.locals import Color, K_q, KEYUP, K_ESCAPE, K_RETURN, K_w, K_a, K_s, K_d
from sprite_strip_anim import SpriteStripAnim
import constants
from animal import Animal
import cat
#import text_input
import os
import utils
import numpy as np
game = utils.Game()
game.cats = []
for i in range(constants.num_cats):
    game.cats.append(cat.Cat())

bg_color = constants.background

pygame.display.set_caption('Cats!')
pygame.display.init()
clock = pygame.time.Clock()

# textinput = text_input.TextInput()

total_strips = [[
    SpriteStripAnim('cat.png', (256+0,0,32,32), 3, 0, True, constants.frames), # Walk Right
    SpriteStripAnim('cat.png', (256+32,0,32,32), 1, 0, True, constants.frames), # Stand lool Right
    SpriteStripAnim('cat.png', (256+0,32,32,32), 3, 0, True, constants.frames), # Walk Up
    SpriteStripAnim('cat.png', (256+32,32,32,32), 1, 0, True, constants.frames), # Stand Up
    SpriteStripAnim('cat.png', (256+0,64,32,32), 3, 0, True, constants.frames), # Walk Down
Ejemplo n.º 11
0
import dog, cat
my_animals = [
    dog.Dog('friendly', 'big'),
    cat.Cat('meow', 'tiny')
]
for my_animal in my_animals:
    print(my_animal.get_info())
Ejemplo n.º 12
0
import animal, dog, cat

anim = animal.Animal('Foo')

anim.speak()

print()
puppy = dog.Dog('Spark', 4)
puppy.speak()

#print(puppy)

print()
kitty = cat.Cat('Fluffy', 'persian')

kitty.speak()
Ejemplo n.º 13
0
 def getSpeciesList(self):
     return [hare.Hare(), cat.Cat()]
Ejemplo n.º 14
0
async def test_forward():
    garfield = cat.Cat('Garfield')
    result = await herd(garfield, 'forward')
    assert result
Ejemplo n.º 15
0
def main():

    list = []

    with open('pets.csv', 'r', newline='') as mycsvfile:

        thedatareader = csv.reader(mycsvfile, delimiter=',', quotechar=',')

        for row in thedatareader:

            if 'Dog' == row[0]:
                writedog = dog.Dog(row[0], row[1], row[2], row[3], row[4])
                list.append(writedog)
            if 'Cat' == row[0]:
                writecat = cat.Cat(row[0], row[1], row[2], row[3], row[4])
                list.append(writecat)
            if 'Fish' == row[0]:
                writefish = fish.Fish(row[0], row[1], row[2], row[3], row[4])
                list.append(writefish)
            if 'Bird' == row[0]:
                writebird = bird.Bird(row[0], row[1], row[2], row[3], row[4])
                list.append(writebird)

    option = 0

    #this displays the menu until the user chooses to exit
    while option != 6:

        print("1. Print only the names of all the pets")
        print("2. Show only pets of a certain type")
        print("3. Search for a pet")
        print("4. Sort the list based on the pet name")
        print("5. Sort list based on pet color")
        print("6. Exit the program")

        option = float(input("Pick your option from 1-6: "))

        while option < 1 or option > 6:

            option = float(
                input(
                    "That was an incorrect option. Pick a valid option from 1-6: "
                ))

        if option == 1:
            print(printnames(list))

        elif option == 2:
            petlist = []
            showpets(list, petlist)

            for item in petlist:
                print(item)

        elif option == 3:
            print(searchpets(list))

        elif option == 4:
            newlist = list
            sortname(list, newlist)

            for item in newlist:
                print(item)

        elif option == 5:
            newlist = list
            sortcolor(list, newlist)

            for item in newlist:
                print(item)
    else:
        exit(0)
Ejemplo n.º 16
0
import cat
import dog
import fox
import pom
import shepherd

animals = [
    cat.Cat('Garfield'),
    dog.Dog('Odie'),
    pom.Pom('Miley'),
    shepherd.Shepherd('General'),
    fox.Fox('Nick P Wilde')
]

for animal in animals:
    print(animal.get_name() + ', ' + animal.speak())
Ejemplo n.º 17
0
#!/usr/bin/env python2.7

import logging
from logging.config import fileConfig

import pet, cat, dog, snake

fileConfig("logging.cfg")

global_logger = logging.getLogger("pet_world")
global_logger.warning("Here we go...!")

d = dog.Dog()
mad_cat = cat.Cat(word="Hiss")
s = snake.Snake()
Ejemplo n.º 18
0
 def test_forward(self):
     garfield = cat.Cat('Garfield')
     self.assertTrue(herd(garfield, 'forward'))
Ejemplo n.º 19
0
 def test_forward(self, move_mock):
     garfield = cat.Cat('Garfield')
     loop = asyncio.get_event_loop()
     result = loop.run_until_complete(herd(garfield, 'forward'))
     move_mock.assert_called_with('forward')
Ejemplo n.º 20
0
import dog, cat
my_animals = [dog.Dog("friendly", "big"), cat.Cat("meow", "tiny")]
for my_animal in my_animals:
    print(my_animal.get_info())
Ejemplo n.º 21
0
import cat

cat1 = cat.Cat("romeo")
cat1.speak()

cat2 = cat.Cat("juliet")
cat2.drink()
Ejemplo n.º 22
0
 def test_forward(self):
     garfield = cat.Cat('Garfield')
     result = self.runner.run_coroutine(herd(garfield, 'forward'))
     self.assertTrue(result)
Ejemplo n.º 23
0
 def test_forward(self):
     garfield = cat.Cat('Garfield')
     result = await herd(garfield, 'forward')
     self.assertTrue(result)
Ejemplo n.º 24
0
import pygame
import telas as t
import uteis as u
import cat as c
import Back as b
import mouse as m
import cloud as cl
import game as g

todas_as_sprites = pygame.sprite.Group()
cat = c.Cat()
back = b.Back()
todas_as_sprites.add(back)
todas_as_sprites.add(cat)

for i in range(3):
    cloud = cl.Cloud()
    todas_as_sprites.add(cloud)

mouse1 = m.Mouse()
mouse2 = m.Mouse()
mouse3 = m.Mouse()
mouse4 = m.Mouse()

todas_as_sprites.add(mouse1, mouse2, mouse3, mouse4)

grupo_obstaculos = pygame.sprite.Group()
grupo_obstaculos.add(mouse1, mouse2, mouse3, mouse4)

grupo_oM1 = pygame.sprite.Group()
grupo_oM1.add(mouse2, mouse3, mouse4)
Ejemplo n.º 25
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()
Ejemplo n.º 26
0
import cat

m = cat.Cat()

m.speed(100)
m.start(2, 6)

m.turn(45)
for i in range(10):

    m.move(8)

    m.turn(90)
    m.move(8)

    m.turn(90)
    m.move(8)

    m.turn(90)
    m.move(8)

    m.turn(90)
Ejemplo n.º 27
0
 def test_forward(self):
     garfield = cat.Cat('Garfield')
     result = asyncio.run(herd(garfield, 'forward'))
     self.assertTrue(result)
Ejemplo n.º 28
0
import serial
import cat
import ft847
import time

io = serial.Serial('/dev/ttyUSB0', baudrate= 57600, bytesize=8, parity = 'N', stopbits=2)
catif = cat.Cat(io)
radio = ft847.Ft847(catif);
print radio.receiverStatus()
print radio.transmitStatus()
print radio.getMainVfoStatus()
#radio.setFrequency(ft847.MAIN_VFO, 123436123456.123)
#radio.setFrequency(ft847.MAIN_VFO, 1123456.123)
radio.setFrequency(ft847.MAIN_VFO, 436000000.123)
#radio.setMainVfoOperatingMode('FM(N)')
#radio.setMainVfoCtcssDcsMode("CTCSS ENC ON")
#radio.setMainVfoCtcssFrequency("114.8")
#radio.setMainVfoDcsCode(754)
radio.setRepeaterShift('-')
radio.setRepeaterOffset(650000)
#Below two might not work if sattellite mode is not enabled
#print radio.getSatRxVfoStatus()
#print radio.getSatTxVfoStatus()
radio.disconnect()

Ejemplo n.º 29
0
import cat

romeo = cat.Cat()

romeo.speak()
romeo.drink()
Ejemplo n.º 30
0
#!/usr/bin/env python3

import dog
import cat

d = dog.Dog('wang cai')
d.bark()

c = cat.Cat('mi mi')
c.bark()