"Write a class named Banger. You will need to write the following methods for it:
__init__(): This method needs to accept the name of the driver (a string) and
the model of the car (also a string). Use the string “unknown” for
the default argument. It should also initialize the number of hits
that the car has received in the game to 0.
__repr__(): This method should return a string that consists of the name of the
driver, followed by a tab, and then the name of the model of the
get_driver(): This method simply returns the name of the driver.
get_model(): This method simply returns the model of the car.
get_hits(): This method returns the number of times the car has been hit
during the course of the derby.
add_hit(): This method adds 1 to the total number of hits."
class Banger(): def __init__(self, driver, modelofcar): self.unknown = driver, modelofcar hits = 0 def __repr__(self): driver = self.get_driver modelofcar = self.get_model return driver + '\t' + modelofcar def get_driver(self): driver = "" return driver def get_model(self): modelofcar = "" return modelofcar
#from Banger import * from random import randint import time #Registration from the file competitors.txt cars =  car_file = open("competitors.txt") for each in car_file: car, type_car = each.split('\t') new_entry = Banger(car.strip(), type_car.strip()) cars.append(new_entry) print("There are now", len(cars), "cars in this here demolition derby.") print("Registration is now closed. Here's who we have in our race:\n") for each in cars: print(each) #Welcome print("\nAnd now it's time for the race!\n") print("Welcome ladies and gentlemen to the CSE 1384 Demolition Derby.") print("We have cars in the arena to rock your world with all of the smashing") print("and crashing that you could ever hope for. It promises to be an") print("exciting night.\n") print("Our returning champion, " + cars.get_driver()+ ", has come tonight") print("with his newest" + cars.get_model()+ ".") print("The race hasn't started yet so he has " + str(cars.get_hits()) + "hits so far,") print("but is he ever mobile.\nYee-haa! Look at him move. Yessiree, it should") print("be a fine show.")