コード例 #1
0
def main(access_port, no_clients, timeout,ft=0, r = 0):
    # logger for the main
    logger = logging.getLogger('Token Ring')

    first_entity = 0
    if r == 1:
        first_entity = ft
    # initial node (Restaurant)
    restaurant_node = Restaurant(5000 + first_entity,4,3)
    restaurant_node.start()
    
    # Clerk
    clerk_node = Clerk(5000 + first_entity,4,3)
    clerk_node.start()

    # Chef
    chef_node_1 = Chef(5000 + first_entity, 4,3)
    #chef_node_2 = Chef(5000 + first_entity, 5, 3, 5004, 4)

    chef_node_1.start()
    #chef_node_2.start()
    
    # Waiter
    waiter_node=Waiter(5000 + first_entity, 4, 3)
    waiter_node.start()
コード例 #2
0
def class_demo():
    student1 = Student("Jim", "Business", 2.1, False)
    print(student1)
    print(f"{student1.name}  {student1.on_honor_roll()}")
    student2 = Student("Phyllis", "Business", 3.8, False)
    print(student2)
    print(f"{student2.name} {student2.on_honor_roll()}")

    chef = Chef("Skc")
    chef.make_special_dish()

    chef1 = ChineseChef("Skc")
    chef1.make_special_dish()
    chef1.make_salad()
    print("========line class Example========")
    coordinate1 = (3, 2)
    coordinate2 = (8, 10)
    line = Line(coordinate1, coordinate2)
    print(
        f"distance between {coordinate1}  and {coordinate2} : {line.distance()}"
    )
    print(f"slope between {coordinate1}  and {coordinate2} : {line.slope()}")

    print("========cylinder class Example========")
    cylinder = Cylinder(2, 3)
    print(f"volume of {cylinder} : {cylinder.volume():1.2f}")
    print(f"surface area of {cylinder} : {cylinder.surface_area():1.1f}")
コード例 #3
0
def main():
    chef: Chef = Chef()

    hamburger_builder: BurgerBuilder = HamburgerBuilder()
    chef.set_builder(hamburger_builder)
    print(chef.cook())

    vegiburger_builder: BurgerBuilder = VegiburgerBuilder()
    chef.set_builder(vegiburger_builder)
    print(chef.cook())
コード例 #4
0
def main():

    restaurant = Restaurant()
    waiter = Waiter()
    chef = Chef()
    clerk = Clerk()

    restaurant.start()
    waiter.start()
    chef.start()
    clerk.start()

    restaurant.join()
    waiter.join()
    chef.join()
    clerk.join()

    return 0
コード例 #5
0
ファイル: simulation.py プロジェクト: HerouFenix/cslp
def main():

    restaurant = Restaurant()
    waiter = Waiter()
    chef = Chef()
    recep = Receptionist()

    restaurant.start()
    waiter.start()
    chef.start()
    recep.start()

    restaurant.join()
    waiter.join()
    chef.join()
    recep.join()

    return 0
コード例 #6
0
def main():

    restaurant = Restaurant(ringSize=4)
    waiter = Waiter(ringSize=4)
    chef = Chef(ringSize=4)
    clerk = Clerk(ringSize=4)

    restaurant.start()
    waiter.start()
    chef.start()
    clerk.start()

    restaurant.join()
    waiter.join()
    chef.join()
    clerk.join()

    return 0
コード例 #7
0
def main():

    restaurant = Restaurant()
    waiter = Receptionist()
    chef = Chef()
    clerk = Employee()

    restaurant.start()
    waiter.start()
    chef.start()
    clerk.start()

    restaurant.join()
    waiter.join()
    chef.join()
    clerk.join()

    return 0
コード例 #8
0
def main():

    restaurant = Restaurant()
    waiter = Waiter()
    chef = Chef()
    clerk = Clerk()

    # O start vai a cada entidade e vai inciar uma thread
    restaurant.start()
    waiter.start()
    chef.start()
    clerk.start()

    restaurant.join()
    waiter.join()
    chef.join()
    clerk.join()

    return 0
コード例 #9
0
# def run_test(questions):
#     score = 0
#     for question in questions:
#         answer = input(question.prompts)
#         if answer == question.answer:
#             score += 1
#     print("You got " + str(score) + '/' + str(len(questions)) + ' correct')
#
# run_test(questions)
#
#


# from Student import Student #take note of 'from _____ import _______ ' format used
#
# student1 = Student("Jim", "Engineering", 3.2, None)
# student2 = Student("Mike", "Art", 3.7, None)
#
# print(student1.on_honor_roll())



from Chef import Chef
from ChineseChef import ChineseChef

myChef = Chef() #This is just making Chef() into myChef for easier call
myChef.make_salad()

myChineseChef = ChineseChef()
myChineseChef.make_special_dish()
コード例 #10
0
# from Chef import Chef
# from ChineseChef import ChineseChef

# myChef = Chef()
# myChef.make_chicken()
# myChef.make_salad()
# myChef.make_special_dish()

# myChef = ChineseChef()
# myChef.make_special_dish()
# myChef.make_fried_rice()

#------------------------------------ Inheritance---------------------------------------------------------------
from Chef import Chef
from ChineseChef import ChineseChef

myChef = Chef()
myChef.make_chicken()
myChef.make_salad()
myChef.make_special_dish()

myChef = ChineseChef()
myChef.make_special_dish()
myChef.make_fried_rice()

myChef.make_chicken(
)  # make chicken method removed from chinese chef but still can access it by inheritance

myChef.make_special_dish()
コード例 #11
0
from Chef import Chef
from Chinese_chef import ChineseChef

my_chef = Chef()
my_chef.make_chicken()
my_chef.make_salad()
my_chef.make_special_dish()
print("---")
my_chinese_chef = ChineseChef()
my_chinese_chef.make_chicken()
my_chinese_chef.make_salad()
my_chinese_chef.make_special_dish()
my_chinese_chef.make_fried_rice()
コード例 #12
0
from Chef import Chef

X = Chef()
X.Faz_Salada()
X.Faz_Jaca()
X.Prato_Especial()

# TypeError: Faz_Salada() missing 1 required positional argument: 'self'
#Estava Faltando o Parenteses no final de -> X = Chef()

from Chefe_Chines import Chinese_Chef

Y = Chinese_Chef()
Y.Arroz()
Y.Faz_Jaca()

#UFA FINALMENTE RESOLVI OS PEPINOS DESTA AULA
コード例 #13
0
from Chef import Chef
from CzechChef import CzechChef

myChef = Chef()
myChef.makeSpecialDish()

myCzechChef = CzechChef()
myCzechChef.makeSpecialDish()
myCzechChef.makeGulas()
コード例 #14
0
ファイル: app.py プロジェクト: jamiemorgan14/python-practice
from Chef import Chef
from ChineseChef import ChineseChef

myChef = Chef()


# myChef.make_chicken()
# myChef.make_salad()
# myChef.make_steak()

myChineseChef = ChineseChef()

myChineseChef.make_steak()
myChef.make_steak()
コード例 #15
0
from Chef import Chef
from Chinese_Chef import Chinese_Chef

chef1 = Chef()
chef1.make_chicken()
chef1.make_salad()
chef1.make_special_dish()
print("==========================")
chinese_chef = Chinese_Chef()
chinese_chef.make_chicken()
chinese_chef.make_salad()
chinese_chef.make_special_dish()
chinese_chef.make_fired_rice()
コード例 #16
0
full_file = open("text_file.txt", "r")  #open a file in read mode
isReadable = full_file.readable()
if isReadable:
    print("The file is readable")
    print(full_file.read())
full_file.close()

print("\n--writing to files--")

full_file = open("text_file.txt", "a")
full_file.write("This is the added stuff")
full_file.close()

print("\n--classes and objects--")  #used to create a custom data type

student1 = Student(
    "Shobhit", "IT", 4,
    False)  #instantiate your Student Class.. create an object of the class
print("Student name is " + student1.name1)

is_on_honor_roll = student1.is_on_honor_roll()
if is_on_honor_roll:
    print(student1.name1 + " is on HonorRoll")

generic_chef = Chef()
chinese_chef = ChineseChef()

print("Generic Chef ki special dish: " + generic_chef.special_dish())
print("Chinese chef ki special dish" + chinese_chef.special_dish())
コード例 #17
0
from Chef import Chef
from ChineseChef import ChineseChef

myChef = Chef()  #creating an object for chef
myChef.make_special_dish()

myChineseChef = ChineseChef()  #creating an object for ChineseChef
myChineseChef.make_special_dish()
コード例 #18
0
from Chef import Chef
from ChineseChef import ChineseChef

myChef = Chef()
myChef.make_salad()

myChineseChef = ChineseChef()
myChineseChef.make_special_salad()
myChineseChef.make_fried_rice()
コード例 #19
0
ファイル: inheritance.py プロジェクト: tsabz/python_practice
from Chinese_Chef import ChineseChef
from Chef import Chef

chef = Chef()
chef.make_chicken()

chienseChef = ChineseChef()
chienseChef.make_chicken()

コード例 #20
0
Student1 = Student('Specky', 'Computer Science', 4.5)
Student2 = Student('Purva', 'Information Technology', 3.5)

print(Student2.on_honor_roll())

print(Student1.is_in_criteria())



from Chef import Chef
from ItaliyanChef import ItaliyanChef
from FrenchChef import FrenchChef
from PersianChef import PersianChef
myItaliyanChef = ItaliyanChef()

myItaliyanChef.make_Rissoto()
myFrenchChef = FrenchChef()

myFrenchChef.make_Creambrulle()
myChef = Chef()
myFrenchChef.make_Special_dish()

myFrenchChef.make_salad()
myFrenchChef.make_chicken()

myPersianChef = PersianChef()
myPersianChef.make_Special_Dish()
myPersianChef.make_chicken()
myPersianChef.make_salad()
コード例 #21
0
import pygame
import sys
from pygame.transform import flip
from Chef import Chef

pygame.init()

size = width, height = 640, 480
speed = [1, 0.5]
black = 0, 0, 0  #Red, Green, Blue
white = 255, 255, 255
red = 255, 0, 0

screen = pygame.display.set_mode(size)

chef = Chef(width, height)
chefrect = chef.rect

for i in range(0, 500):
    chef.y = chef.y + 1

    screen.fill(red)
    screen.blit(chef.image, chefrect)
    pygame.display.flip()
    print(i)
'''
t = 0
while 1:
    for event in pygame.event.get():
        if event.type == pygame.QUIT: 
            sys.exit()
コード例 #22
0
ファイル: inheret.py プロジェクト: PionDas/reviewPython
from Chef import Chef
from ChineseChef import ChineseChef

myChef = Chef()
myChef.make_special_dish()

myChineseChef = ChineseChef()
myChineseChef.make_special_dish()
コード例 #23
0
def on_honor_roll(self):  #Place in first file with student class
    if self.gpa >= 3.5 #checking to see if student gpa is in honor roll
        return True #What function can I put inside of here to help the user figure out information about the object
    else:
        return False 
print(student1.on_honor_roll()) #false
print(student2.on_honor_roll()) #true
-----------------------------------------------------
INHERTIANCE: where we can define attributes and functions inside of class
then create another class that inherits everything without writing the same
methods or attributes.

First file:
'''from Chef import Chef #importing the chef so we can use it'''
from ChineseChef import ChineseChef
myChef = Chef() #creating a new Chef 
myChef.make_chicken() #The chef makes a chick
myChef.make_special_dish() #makes bbq

myChineseChef = ChineseChef()
myChineseChef.make_fried_rice()

#lets create a class that modeled a Chinese Chef instead of normal chef.
#first crete a new file ChineseChef.py
1. class ChineseChef:#very specific and can do everything the other chef can do
2. #if we want to give him all of the functionality we can just copy info from previous file
class ChineseChef:
     def make_chicken(self): #the problem is we had to copy and paste the physical file
        print("The chef makes a chicken")
    def make_salad(self):
        print("The chef makes salad")
コード例 #24
0
# Title:                            Inheritance in Python
# Author:                           Sachin Kotian
# Created date (DD-MM-YYYY):        08-12-2018
# Last modified date (DD-MM-YYYY):  08-12-2018
#
# ABOUT:
# This code imports the "Chef" and "ChineseChef" class
# ChineseChef inherits all the function from Chef
# Please refer to "Chef.py" and "ChineseChef.py" for the class code

# Importing the Chef and ChineseChef classes
from Chef import Chef
from ChineseChef import ChineseChef

# Defining the chefs 1 and 2
myChef1 = Chef()
myChef2 = ChineseChef()

# Calling the functions of the classes
myChef1.makes_chicken()
myChef1.makes_special_dish()
myChef2.makes_fried_rice()
myChef2.makes_salad()
コード例 #25
0
from Chef import Chef
from ChineseChef import ChineseChef

myChef = Chef()
myChineseChef = ChineseChef()

myChef.MakeSpecialdish()
myChineseChef.MakeSpecialdish()
コード例 #26
0
ファイル: Inheritance.py プロジェクト: Stoorrzi/pythonProject
from Chef import Chef
from ChineseChef import ChineseChef

myChef = Chef()
myChef.make_special()

myChineseChef = Chef()
myChineseChef.make_chicken()


コード例 #27
0
#Inheritance  # we can define a class and define some attributes and functions in the class and then use this class in some other class

from Chef import Chef

myChef = Chef()
myChef.make_chicken()

#now if we want to make a class that model a different type of chef
#lets see our Chinese Chef

from ChineseChef import ChineseChef

myChineseChef = ChineseChef()
myChineseChef.make_special_dish()
myChineseChef.make_chicken()


from ChineseChef import ChineseChef_import

myChineseChef = ChineseChef_import()
myChineseChef.make_special_dish()
myChineseChef.make_chicken()

コード例 #28
0
from ChineseChef import ChineseChef
from Chef import Chef
from ChineseChef import ChineseChef

myChef = Chef("홍길동")
myChef.make_chicken()

myChineseChef = ChineseChef("일지매")
print("중국세프 이름: " + myChineseChef.name)
myChineseChef.make_fried_rice()
myChineseChef.make_salad()
myChineseChef.make_special_dish()
コード例 #29
0
ファイル: app.py プロジェクト: cjvalverde/Python_playground
from Chef import Chef
from ChineseChef import ChineseChef

myChef = Chef()
myChef.make_chicken()
myChef.make_special_dish()

myChineseChef = ChineseChef()
myChineseChef.make_chicken()
myChineseChef.make_fried_rice()
myChineseChef.make_special_dish()
コード例 #30
0
from Chef import Chef
from ChineseChef import ChineseChef

c = Chef()
cc = ChineseChef()

c.make_special()
cc.make_special()