Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

Question

In python

  • 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.

Examples:

Copy the following if __name__ == "__main__" block into your hw11.py file, and comment out tests for parts of the class you haven’t implemented yet. The lines that have output include the expected value next to them as a comment (note that some lines are random and your output will not match exactly).

The first race example in the code below should finish within a few turns, and unless you get extremely unlucky, The Leaf should win a solo victory almost every time due to its top speed. The second race, on the other hand, should almost always finish in a single round with three or four boats tied for victory.

if __name__ == '__main__':

the_race = BoatRace('the_big_one.csv')

the_race.add_racer(Boat("Late", 2))

the_race.print_racers() #The Fire Ball: 0

#The Leaf: 0

#Late: 0

print(the_race.count()) #3

result = the_race.race() #The Fire Ball: 5

#The Leaf: 39

#Late: 2

#The Fire Ball: 17

#The Leaf: 56

#Late: 4

#The Fire Ball: 19

#The Leaf: 145

#Late: 4

print(result) #[<__main__.Boat object at 0x03A2E4F0>]

print(result[0].get_boat_name()) #The Leaf

print(result[0].get_current_progress()) #145

second_race = BoatRace('very_short.csv')

second_result = second_race.race() #Runner: 84

#Whirlwind: 10

#Boaty McBoatFace: 4

#Greased Lightning: 78

#Much Speed: 43

print(len(second_result)) #4

Expert Solution
Check Mark
Knowledge Booster
Background pattern image
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
    Text book image
    Database System Concepts
    Computer Science
    ISBN:9780078022159
    Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
    Publisher:McGraw-Hill Education
    Text book image
    Starting Out with Python (4th Edition)
    Computer Science
    ISBN:9780134444321
    Author:Tony Gaddis
    Publisher:PEARSON
    Text book image
    Digital Fundamentals (11th Edition)
    Computer Science
    ISBN:9780132737968
    Author:Thomas L. Floyd
    Publisher:PEARSON
    Text book image
    C How to Program (8th Edition)
    Computer Science
    ISBN:9780133976892
    Author:Paul J. Deitel, Harvey Deitel
    Publisher:PEARSON
    Text book image
    Database Systems: Design, Implementation, & Manag...
    Computer Science
    ISBN:9781337627900
    Author:Carlos Coronel, Steven Morris
    Publisher:Cengage Learning
    Text book image
    Programmable Logic Controllers
    Computer Science
    ISBN:9780073373843
    Author:Frank D. Petruzella
    Publisher:McGraw-Hill Education