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)

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter10: Introduction To Inheritance
Section: Chapter Questions
Problem 6PE
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
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage