Question: please modify the code to meet the requirements and expected outputs with inputs You will create a class to represent a Domino in the game

please modify the code to meet the requirements and expected outputs with inputs
You will create a class to represent a Domino in the game of Dominos.
Your Domino class must have the following attributes and methods: Attributes:
side1 and side2 to store the number of pips on each side of the domino Methods:
a constructor
an __str__ method -- note most of the testing works based on this so it is important to get this done first class Domino:
# define constructor with parameters
# and initializes the instances attributes, side1, and side2
# define a __str__ method that returns the domino as a string in the form
# [side1 side2] where both sides are formatted with
# a field width of 2, where a side is 0,__ is displayed instead
#--------------------------------------------------------------------------
# DO NOT CHANGE THIS METHOD
def __repr__(self):
"""
DO NOT CHANGE!
Helper for allowing print (and pprint) to print the domino
"""
return str(self)
#--------------------------------------------------------------------------
# define the is_double method that returns true if and only if both sides of the domino are equal, and false otherwise
# define the is_single method that returns true if and only if the both sides of the domino are different, and false otherwise
# define the is_blank method that returns true if and only if the tile has, at least, one side blank and false otherwise
# define the matches(self, other) method that returns true if self matches the other domino. self matches when it's second side matches one of the sides of
# the other domino. In the case that side2 matches side2 of the other, then other must be flipped.
# However, note that we never flip self -- meaning that when only side1 is equal to one of other's sides
# we do NOT flip self
# define the flip method that flips side1 with side2. So for example a domino [1,5] flipped would be [5,1]
# define the weight method that returns the total weight of the domino.
# The weight is the total number of pips on a domino, unless the domino is a double blank.
# The weight of the double blank is 50.
# define the major_suit method that returns the bigger side. For example, the major suit of [4,2] is 4.
# define the minor_suit method that returns the smaller side. For example, the minor suit of [4,1] is 1.
# Your code to read in the value of two sides of the Domino
# and then print the domino using its __str__ method
domino = Domino(s1, s2)
print(domino)
print(domino.is_double())
print(domino.is_single())
print(domino.is_blank())
print(domino.weight())
print(domino.major_suit())
print(domino.minor_suit())
domino.flip()
print(domino)
d2= Domino(domino.side1,666)
print(domino.matches(d2))
d2= Domino(666, domino.side1)
print(domino.matches(d2))
print(d2)
print(domino.matches(Domino(12345,6789)))
Input
1
5
Expected output
[{:[1,5]]
False
True
False
6
5
1[15]
False
True
False
6
5
1
[51]
False
Falge
[6665]
False
Input
0
0
Expected output
[__]
True
Falss
True
50
0
0
[__]
True
True
[666]
False
[51]
False
False
[6665]
False
please modify the code to meet the requirements

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 Accounting Questions!