In this exercise you will create a Pass
class that will later be used in a graph structure to analyze the passing behavior in a sports team.
Create a Python class Pass
with the following features:
sender
— the Player object that makes the pass.receiver
— the Player object that receives the pass.nr_of_times
(int) — the number of times this pass occurred in the match.sender
, receiver
, and nr_of_times
as parameters and stores them in the instance variables.Method get_weight
returns the number of times this pass occurred (nr_of_times
).
Method get_start
returns the sender
.
Method get_end
returns the receiver
.
__eq__
True
if:
other
is also a Pass
, andsender
and receiver
.nr_of_times
value does not matter for equality.__str__
returns a string in the format:
Pass from <sender> to <receiver>
Examples:
Pass from Eden Hazard to Moussa Dembele
Pass from Jan Vertonghen to Romelu Lukaku
Pass from Divock Origi to Nacer Chadli
Create the following test scenario:
Player
objects.Pass
objects.Pass
object to the console.__eq__
method.get_weight
method.