コード例 #1
0
    def draw(self, screen):
        """Draw the player."""

        if self.fat_count < 30:
            self.fat_count = 30

        self.size_x = self.fat_count
        self.size_y = self.fat_count * 2 / 3

        img = None

        if self.jumping:
            img = pygame.image.load(self.images.jumping)
        else:
            img = pygame.image.load(self.images.default)
        img = pygame.transform.scale(img, (int(self.size_x), int(self.size_y)))

        #pygame.draw.rect(screen, WHITE,
        #                 [self.pos_x, self.pos_y, self.size_x, self.size_y])
        # pygame.draw.rect(screen, self.color,
        #                [self.pos_x + 10, self.pos_y + 10, self.size_x - 10, self.size_y - 10])

        screen.blit(img, (self.pos_x, self.pos_y))
        # self.text_print.indent()
        # self.text_print.print(screen, "Player message: {}".format(self.debug))

        if self.has_sandwich:
            Sandwich.draw(screen,
                          self.pos_x,
                          pos_y=self.pos_y - Sandwich.sandwich_tall)
コード例 #2
0
def sandwich_test(xs, ys, num_pos, num_neg, n, c, err, err1k, epochs):
    """
    Perform a test on the sandwich learned filter
    """
    sandwich = Sandwich(n, c, err, num_pos, err1k)
    print(sandwich)

    print("Training sandwich...")
    sandwich.train(xs, ys, epochs)

    print("Testing sandwich...")
    false_pos = false_neg = 0
    for x, y in zip(xs, ys):
        filter_contains = bool(sandwich.contains(x))
        false_pos += not y and filter_contains
        false_neg += y and not filter_contains

    print(sandwich)
    print("fpr: {}, fnr: {}, correct%: {}".format(
        false_pos / num_neg, false_neg / num_pos,
        1 - (false_pos + false_neg) / (num_pos + num_neg)))
コード例 #3
0
    def order_sandwich(self):
        while True:
            self.show_menu()
            order = input("메뉴를 선택해주세요. (ENTER : 계산/종료)")
            if order == "":
                break
            self.name = Order._menus[int(order)]
            self.order()

            self.order_menu.append(self.name)

        # 주문 결과 출력
        print("------------------------- 주문 내역 -------------------------")
        total = Sandwich(self.name) #네임은 메뉴이름이다. 오더에서 받은 네임을 샌드위치 __init__에 적용한다.
        print(total)
コード例 #4
0
def loadOrderFromTextFile(filename):
    order = Order()
    txtfile = open(filename, 'r')
    sandwichstrings = txtfile.readlines()
    for sandwichstring in sandwichstrings:
        sandwichstring = sandwichstring[0:-1]
        print(sandwichstring)
        sandwichvars = json.loads(sandwichstring)
        sandwich = Sandwich(sandwichvars['name'])
        if (sandwichvars['bread'] != None):
            sandwich.setBread(sandwichvars['bread'])
        if (sandwichvars['cheese'] != None):
            sandwich.setCheese(sandwichvars['cheese'])
        if (sandwichvars['meat'] != None):
            sandwich.setMeat(sandwichvars['meat'])
        if (sandwichvars['condiments'] != None):
            for condiment in sandwichvars['condiments']:
                sandwich.addCondiment(condiment)
        if (sandwichvars['toasted'] != None):
            sandwich.setToasted(sandwichvars['toasted'])
        order.addSandwich(sandwich)
    return order
コード例 #5
0
            sandwich.setBread(sandwichvars['bread'])
        if (sandwichvars['cheese'] != None):
            sandwich.setCheese(sandwichvars['cheese'])
        if (sandwichvars['meat'] != None):
            sandwich.setMeat(sandwichvars['meat'])
        if (sandwichvars['condiments'] != None):
            for condiment in sandwichvars['condiments']:
                sandwich.addCondiment(condiment)
        if (sandwichvars['toasted'] != None):
            sandwich.setToasted(sandwichvars['toasted'])
        order.addSandwich(sandwich)
    return order


if __name__ == "__main__":
    s1 = Sandwich("Joe")
    s1.setMeat("steak")
    s1.addCondiment("Lettuce")
    print(s1)

    s2 = Sandwich("Mary")
    s2.setCheese("cheddar")
    s2.addCondiment("Mayo")
    print(s2)

    print("Order 1:")
    order = Order()
    print(order)
    order.addSandwich(s1)
    print(order)
    print("Total Price:" + str(order.price()))
コード例 #6
0
"""
Tests for Sandwich and Order classes.
Test for writing the order object to a binary file.
"""

from order import Order
from sandwich import Sandwich
import pickle

# create Sandwich objects
s1 = Sandwich("Joe")
s1.setMeat("steak")
s1.addCondiment("Lettuce")
print(s1)
print(s1.getPrice())

s2 = Sandwich("Mary")
s2.setCheese("cheddar")
s2.addCondiment("Mayo")
print(s2)
print(s2.getPrice())

s3 = Sandwich("Elizabeth")
s3.setBread("sourdough")
s3.setMeat("ham")
s3.setCheese("swiss")
s3.addCondiment("mayo")
s3.addCondiment("mustard")
s3.setToasted(True)
print(s3)
print(s3.getPrice())
コード例 #7
0
# Assignment-05.py
# Teo Espero
# 20200518
# Objectives:
#       Create a new, reusable class
#       Develop a program to test the new class that is separate from the new class itself

# this allows us to use the objects and methods defined in the sandwich.py module
from sandwich import Sandwich

# the following tests are from the assignment page themselves

print('\n--------------------------------------')
print('Test data in the assignment')
print('--------------------------------------')
s = Sandwich("Bennie")
print(s)
print(s.price())
s.setBread("wheat")
print(s)
print(s.price())
s.setCheese("Cheddar")
print(s)
print(s.price())
s.setMeat("turkey")
print(s)
print(s.price())
s.addCondiment("mayo")
print(s)
print(s.price())
s.addCondiment("mustard")
コード例 #8
0
ファイル: main.py プロジェクト: jessepiza/Tarea1_Diseno
    """
    if adi == 'jalapeno':
        cost = 1500
    elif adi == 'pepinillo':
        cost = 650
    elif adi == 'cebolla':
        cost = 700
    elif adi == 'tomate':
        cost = 800
    else:
        raise Exception('La adición ingresada no existe.')
    return cost


# Ejemplo con varios adicionales
sandwich1 = Sandwich('JyQ')  #Sandwich de Jamón y Queso
total1, pedido_tot1 = addition(sandwich1, ['tomate', 'cebolla'])
print(pedido_tot1)

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

#Ejemplo con un solo adicional
sandwich2 = Sandwich('RB')  #Sandwich de Roast Beef
total2, pedido_tot2 = addition(sandwich2, 'pepinillo')
print(pedido_tot2)

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

#Ejemplo sin adicionales
sandwich3 = Sandwich('Ita')  #Sandwich italiano
total3, pedido_tot3 = addition(sandwich3)
コード例 #9
0
    # Opens filename for reading and makes a copy of it in a new file named 'dataCopy.txt'.

    file = open('sandwichObject.txt', 'r')
    file_contents = file.read()
    file.close()
    return file_contents
    ############################


print('\n----------------------------------------------')
############################
# Test data from assignment

# 1st Order, 1st sandwich
print('Test data from assignment:')
s1 = Sandwich("Joe")
s1.setMeat("steak")
s1.addCondiment("Lettuce")
print(s1)

############################
# store Order1 as a Pickle file

myDict = {}
for attr, value in s1.__dict__.items():
    myDict[attr] = value

createFile(myDict)

# 1st Order, 2nd sandwich
s2 = Sandwich("Mary")