ow do I create a class Battle, with the following instance attributes:  iron_chef: a Chef object challenger: a Chef object  secret_ingredient: a string (the ingredient to be used by the chefs in this battle)  dishes: a list of Dish objects  outcome: an empty string   The Battle class should also have the following instance method:  conclude: Make the critics rate the dishes in the battle, and then set the outcome attribute to either 'iron_chef', 'challenger', or 'tie' based on the results. (Whichever chef gets a higher total rating across all dishes is declared the winner.) SO basically rate every dish (by calling rate_dish ON a specific dish), and keep track of the score of each chef - so you need to check which chef is responsible for each dish basically.   BELOW IS THE CODE I HAVE --------------------------------------   import random class Chef:     def __init__(self, name, record, cuisine):         ''' (string, tuple, string) -> Chef '''         self.name = name         self.record = record         self.cuisine = cuisine[:]              def __str__(self):         s = "Chef name: \t" + self.name         s += "\nRecord: \t" + str(self.record)         s += "\nCuisine: \t" + self.cuisine         return s          class Dish:     def __init__(self, name, ingredients, chef, ratings):         '''(string, list, chef, list) -> Dish'''         self.name = name         self.ingredients = ingredients[:]         self.chef = chef         self.ratings = ratings              def rate_dish(self):         if len(self.ratings) >= 4:             self.ratings = []         for i in range(4):             self.ratings.append(random.randint(0, 10))              def __str__(self):         s = "Dish name: \t" + self.name         s += "\nIngredients:\n"         for i in self.ingredients:             s += "\t\t-" + str(i) + "\n"         s += "Chef: \t\t" + str(self.chef.name) + "\n"         s += "Ratings: \t" + str(self.ratings)         return s class Battle:     def __init__(self, iron_chef, challenger, secret_ingredient, dishes, outcome=''):         '''(Chef, Chef, string, list, string) -> Battle'''         self.iron_chef = iron_chef         self.challenger = challenger         self.secret_ingredient = secret_ingredient         self.dishes = dishes         self.outcome = outcome

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

How do I create a class Battle, with the following instance attributes: 

iron_chef: a Chef object

challenger: a Chef object 

secret_ingredient: a string (the ingredient to be used by the chefs in this battle) 

dishes: a list of Dish objects 

outcome: an empty string

 

The Battle class should also have the following instance method: 

conclude: Make the critics rate the dishes in the battle, and then set the outcome attribute to either 'iron_chef', 'challenger', or 'tie' based on the results. (Whichever chef gets a higher total rating across all dishes is declared the winner.) SO basically rate every dish (by calling rate_dish ON a specific dish), and keep track of the score of each chef - so you need to check which chef is responsible for each dish basically.

 

BELOW IS THE CODE I HAVE

--------------------------------------

 

import random

class Chef:
    def __init__(self, name, record, cuisine):
        ''' (string, tuple, string) -> Chef '''
        self.name = name
        self.record = record
        self.cuisine = cuisine[:]
        
    def __str__(self):
        s = "Chef name: \t" + self.name
        s += "\nRecord: \t" + str(self.record)
        s += "\nCuisine: \t" + self.cuisine
        return s
        
class Dish:
    def __init__(self, name, ingredients, chef, ratings):
        '''(string, list, chef, list) -> Dish'''
        self.name = name
        self.ingredients = ingredients[:]
        self.chef = chef
        self.ratings = ratings
        
    def rate_dish(self):
        if len(self.ratings) >= 4:
            self.ratings = []
        for i in range(4):
            self.ratings.append(random.randint(0, 10))
        
    def __str__(self):
        s = "Dish name: \t" + self.name
        s += "\nIngredients:\n"
        for i in self.ingredients:
            s += "\t\t-" + str(i) + "\n"
        s += "Chef: \t\t" + str(self.chef.name) + "\n"
        s += "Ratings: \t" + str(self.ratings)
        return s

class Battle:
    def __init__(self, iron_chef, challenger, secret_ingredient, dishes, outcome=''):
        '''(Chef, Chef, string, list, string) -> Battle'''
        self.iron_chef = iron_chef
        self.challenger = challenger
        self.secret_ingredient = secret_ingredient
        self.dishes = dishes
        self.outcome = outcome

Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Similar questions
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY