Python help please! Thank you! Add the following methods to your Boat Race class: Write a method called add_racer which takes in a Boat object and adds it to the end of the racers list. The function does not return anything.   Write a method called print_racers which loops through racers and prints the Boat objects. This function takes in no parameters (other than self) and returns nothing.   Write a method called count that returns the number of racers.   Write a method called race.  The race function calls the move function for all of the racers in the BoatRace.  Once all the racers have moved, call the print_racers method to display information about the progress of each boat. Then, check if any of the racer’s current_progress is greater than or equal to the race’s distance.  If so, then return a list of all of the racers whose current_progress is greater than or equal to distance.  If no racer has finished the race then repeat the calls to move and check until at least one racer has finished the race. This is what I have so far: class BoatRace:     def __init__(self, file_name):         self.file_name = file_name         with open(self.file_name, 'r') as file:             lines = file.readlines()             self.race_name = lines[0].split(",")[1].strip()             self.race_id = int(lines[1].split(",")[1].strip())             self.distance = int(lines[2].split(",")[1].strip())             self.racers = []             for i in range(3, len(lines)):                 self.racers.append(Boat(lines[i].split(",")[0].strip(), int(lines[i].split(",")[1].strip())))     def get_race_name(self):         return self.race_name     def get_race_id(self):         return self.race_id     def get_distance(self):         return self.distance     def get_racers(self):         return self.racers     def add_racer(self):         self.racers.append(boat)

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

Python help please! Thank you!

Add the following methods to your Boat Race class:

  • Write a method called add_racer which takes in a Boat object and adds it to the end of the racers list. The function does not return anything.

 

  • Write a method called print_racers which loops through racers and prints the Boat objects. This function takes in no parameters (other than self) and returns nothing.

 

  • Write a method called count that returns the number of racers.

 

  • Write a method called race. 
    • The race function calls the move function for all of the racers in the BoatRace. 
    • Once all the racers have moved, call the print_racers method to display information about the progress of each boat.
    • Then, check if any of the racer’s current_progress is greater than or equal to the race’s distance. 
    • If so, then return a list of all of the racers whose current_progress is greater than or equal to distance. 
    • If no racer has finished the race then repeat the calls to move and check until at least one racer has finished the race.

This is what I have so far:

class BoatRace:
    def __init__(self, file_name):
        self.file_name = file_name
        with open(self.file_name, 'r') as file:
            lines = file.readlines()
            self.race_name = lines[0].split(",")[1].strip()
            self.race_id = int(lines[1].split(",")[1].strip())
            self.distance = int(lines[2].split(",")[1].strip())
            self.racers = []

            for i in range(3, len(lines)):
                self.racers.append(Boat(lines[i].split(",")[0].strip(), int(lines[i].split(",")[1].strip())))

    def get_race_name(self):
        return self.race_name

    def get_race_id(self):
        return self.race_id

    def get_distance(self):
        return self.distance

    def get_racers(self):
        return self.racers

    def add_racer(self):
        self.racers.append(boat)

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Unreferenced Objects
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education