Question: POINT CLASS CODE class Point: def __init__(self, x = 0, y = 0): self.x = x self.y = y self.distance = self.distance_from_zero() if self.distance >

 POINT CLASS CODE class Point: def __init__(self, x = 0, y

POINT CLASS CODE

class Point:

def __init__(self, x = 0, y = 0):

self.x = x

self.y = y

self.distance = self.distance_from_zero()

if self.distance > 4:

self.score = 0

if self.distance > 3 and self.distance

self.score = 10

if self.distance > 2 and self.distance

self.score = 20

if self.distance > 1 and self.distance

self.score = 50

if self.distance

self.score = 100

def distance_from_zero(self):

return math.sqrt(self.x ** 2 + self.y ** 2)

def get_score(self):

return self.score

def __str__(self):

return '({}, {})'.format(self.x, self.y)

Define a class named Player which represents a player in the Dart Game. The Player class contains the following: - A data field named name that defines the name of a Player object. - A data field named points that defines a list of Point objects. - A constructor/initializer that takes the name of a player and the seed number as parameters and creates a Player object. The default value of the seed number is 30 . The initializer should set the seed number and the name of the player to the corresponding paramets list to an empty list. - A method named make_throw(self) which simulates a dart throw. The method generates two random integer numbers corresponding to the two coordinates of the dart between 5 and 5 inclusive. Use the random. randrange () method to generate the numbers. Then the function creates a Point object using the two random integers and appends the object to the list of points. The method should also print a message as shown in the examples below. - A method named get_score(self) which returns the score of the last Point object in the list of points. - A method named get_total_score(self) which returns the total score of the player. The total score is obtained by adding up the scores of all the individual points. - A method named get_name (self) which returns the name of the player. - A method named __str__ (self) which returns the string representation of the Player object as shown in the examples below. Notes: - Do not import the random module. This has been done for you as part of the CodeRunner question. - Submit the class definition in the answer box below assuming that the Point class is given. - Keep a copy of your solution to this task because you will be extending it step by step in subsequent tasks. - The seed number must be used for any randomisation as Python program must generate the same output when given the same seed

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!