Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Kitchen:
- """A facility for interpreting the esoteric language 'Chef'.
- """
- def __init__(self, recipe=""):
- """Constructor
- Initializes lists for mixing bowls and baking dishes and
- begins evaluating the recipe (taken in as a string).
- """
- self.mixing_bowls = list()
- self.baking_dishes = list()
- class Bowl:
- """One mixing bowl allowing for the basic operations.
- """
- def __init__(self):
- self.items = list()
- def put(self, ingredient):
- pass
- def fold(self, ingredient):
- pass
- def add(self, ingredient):
- pass
- def remove(self, ingredient):
- pass
- def combine(self, ingredient):
- pass
- def divide(self, ingredient):
- pass
- def mix(self):
- pass
- def liquefy(self, ingredient):
- pass
- # etc
- class Dish:
- """One baking dish allowing for the basic operations.
- """
- def __init__(self):
- self.items = list()
- def pour(self, other):
- """Pours this baking dish into another.
- """
- pass
- def do(self, s):
- """Does an arbitrary operation from a valid Chef string
- The command must be the first word, case sensitive.
- If the command does not exist, None is returned.
- The rest of the string is passed to the desired function as a list.
- """
- t = s.split()
- f = getattr(self, t[0])
- return f(t[1:])
- def __repr__(self):
- return " Mixing Bowls: {mb}\nBaking Dishes: {bd}".format(mb=str(self.mixing_bowls), bd=str(self.baking_dishes))
- # Have this function declare a 2D array of strings, where each dimension will declare a grade of messiness
- # so it can be called
- # ... return arr[len(mixing_bowls) // 5][len(baking_dishes) // 5]
- # or something like that.
- def __str__(self):
- return "You see a mess of utensils; you have a lot of work yet to do."
- def _get_bowl(self, s):
- """Returns the mixing bowl specified by this string.
- This method searches the string provided for the mixing bowl needed:
- >>> getDish("Pour the 3rd mixing bowl into the 2nd baking dish.")
- 3
- If no ordinal for a mixing bowl is specified, it defaults to 1:
- >>> getDish("Put zucchinis into the mixing bowl.")
- 1
- If there is no mention of any mixing bowls, this function returns None:
- >>> getDish("I've got poop for brains.")
- None
- """
- pass
- return 0
- def _get_dish(self, s):
- """Returns the baking dish specified by this string.
- This method searches the string provided for the baking dish needed:
- >>> getDish("Pour the 3rd mixing bowl into the 2nd baking dish")
- 2
- If no ordinal for a baking dish is specified, it defaults to 1:
- >>> getDish("Pour the 3rd mixing bowl into the baking dish")
- 1
- If there is no mention of any baking dishes, this function returns None:
- >>> getDish("I've got poop for brains.")
- None
- """
- pass
- return 0
- def take(self, s):
- """Take (ingredient) from refrigerator.
- This reads a numeric value from STDIN into
- the ingredient named, overwriting any
- previous value.
- """
- pass
- return s
- def put(self, s):
- """Put (ingredient) into the [nth] mixing bowl.
- This puts the ingredient into the nth mixing bowl.
- """
- pass
- return s
- return s
- def fold(self, s):
- """Fold (ingredient) into [nth] mixing bowl.
- This removes the top value from the nth mixing bowl and places it in the ingredient.
- """
- pass
- return s
- def add(self, s):
- """Two uses.
- Add (ingredient) [to [nth] mixing bowl].
- This adds the value of ingredient to the
- value of the ingredient on top of the
- nth mixing bowl and stores the result
- in the nth mixing bowl.
- Add dry ingredients [to [nth] mixing bowl].
- This adds the values of all the dry ingredients
- together and places the result into the
- nth mixing bowl.
- """
- pass
- return s
- def remove(self, s):
- """Remove ingredient [from [nth] mixing bowl].
- This subtracts the value of ingredient from
- the value of the ingredient on top of the
- nth mixing bowl and stores the result in
- the nth mixing bowl.
- """
- pass
- return s
- def combine(self, s):
- """Combine ingredient [into [nth] mixing bowl].
- This multiplies the value of ingredient by
- the value of the ingredient on top of
- the nth mixing bowl and stores the result
- in the nth mixing bowl.
- """
- pass
- return s
- def divide(self, s):
- """Divide ingredient [into [nth] mixing bowl].
- This divides the value of ingredient into
- the value of the ingredient on top of
- the nth mixing bowl and stores the result
- in the nth mixing bowl.
- """
- pass
- return s
- def liquefy(self, s):
- """Two uses.
- Liquefy | Liquify ingredient.
- This turns the ingredient into a liquid,
- i.e. a Unicode character for output purposes.
- (Note: The original specification used
- the word "Liquify", which is a spelling
- error. "Liquify" is deprecated.
- Use "Liquefy" in all new code.)
- Liquefy | Liquify contents of the [nth] mixing bowl.
- This turns all the ingredients in the nth mixing bowl
- into a liquid, i.e. a Unicode characters for
- output purposes.
- """
- pass
- return s
- def stir(self, s):
- """Two uses.
- Stir [the [nth] mixing bowl] for number minutes.
- This "rolls" the top number ingredients
- in the nth mixing bowl, such that the
- top ingredient goes down that number of
- ingredients and all ingredients above it
- rise one place. If there are not that many
- ingredients in the bowl, the top ingredient
- goes to tbe bottom of the bowl and all
- the others rise one place.
- Stir ingredient into the [nth] mixing bowl.
- This rolls the number of ingredients
- in the nth mixing bowl equal to
- the value of ingredient, such that
- the top ingredient goes down that number
- of ingredients and all ingredients above
- it rise one place. If there are not that
- many ingredients in the bowl, the top
- ingredient goes to tbe bottom of the bowl
- and all the others rise one place.
- """
- pass
- return s
- def mix(self, s):
- """Mix [the [nth] mixing bowl] well.
- This randomises the order of the
- ingredients in the nth mixing bowl.
- """
- pass
- return s
- def clean(self, s):
- """Clean [nth] mixing bowl.
- This removes all the ingredients
- from the nth mixing bowl.
- """
- pass
- return s
- def pour(self, s):
- """Pour contents of the [nth] mixing bowl into the [pth] baking dish.
- This copies all the ingredients from
- the nth mixing bowl to the
- pth baking dish, retaining the order
- and putting them on top of anything
- already in the baking dish.
- """
- pass
- return s
- def set(self, s):
- """Set aside.
- This causes execution of the innermost
- loop in which it occurs to end
- immediately and execution
- to continue at the statement after
- the "until".
- """
- pass
- return s
- def serve(self, s):
- """Two uses.
- Serve with auxiliary-recipe.
- This invokes a sous-chef to immediately
- prepare the named auxiliary-recipe.
- The calling chef waits until the sous-chef
- is finished before continuing.
- See the section on auxiliary recipes below.
- Serves number-of-diners.
- This statement writes to STDOUT the contents
- of the first number-of-diners baking dishes.
- It begins with the 1st baking dish,
- removing values from the top one by one and
- printing them until the dish is empty,
- then progresses to the next dish, until all
- the dishes have been printed.
- The serves statement is optional, but is
- required if the recipe is to output anything!
- """
- pass
- return s
- def refrigerate(self, s):
- """Refrigerate [for number hours].
- This causes execution of the recipe
- in which it appears to end immediately.
- If in an auxiliary recipe, the auxiliary
- recipe ends and the sous-chef's first
- mixing bowl is passed back to the calling
- chef as normal. If a number of hours is
- specified, the recipe will print out its
- first number baking dishes before ending.
- """
- pass
- return s
- prompt = 'C='
- kills = ["quit","exit","stop","kill","term"]
- k = Kitchen()
- cmd = raw_input(prompt)
- while cmd[:4] not in kills: # checks the first for letters
- print k.do(cmd)
- print repr(k)
- cmd = raw_input(prompt)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement