Answer:
Step-by-step explanation:
The following class is written in Python, it has the three instance variables that were requested. It also contains a constructor that takes in those variables as arguments. Then it has functions to update the positions of the Dot and change its color. The class also has functions to output current position and color.
class Dot:
"""Class Dot"""
x_coordinate = 0
y_coordinate = 0
color = ""
def __init__(self, x_coordinate, y_coordinate, color):
"""Constructor that takes x and y coordinates as integers and a string for color. It ouputs nothing but saves these argument values into the corresponding instance variables."""
self.x_coordinate = x_coordinate
self.y_coordinate = y_coordinate
self.color = color
def moveUp(self, number_of_spaces):
"""Moves the Dot up a specific number of spaces that is passed as a parameter. Updates y_position"""
self.y_coordinate += number_of_spaces
return ""
def moveDown(self, number_of_spaces):
"""Moves the Dot down a specific number of spaces that is passed as a parameter. Updates y_position"""
self.y_coordinate -= number_of_spaces
return ""
def moveLeft(self, number_of_spaces):
"""Moves the Dot left a specific number of spaces that is passed as a parameter. Updates x_position"""
self.x_coordinate -= number_of_spaces
return ""
def moveRight(self, number_of_spaces):
"""Moves the Dot right a specific number of spaces that is passed as a parameter. Updates x_position"""
self.x_coordinate += number_of_spaces
return ""
def dot_position(self):
"""Print Dot Position"""
print("Dot is in position: " + str(self.x_coordinate) + ", " + str(self.y_coordinate))
return ""
def dot_color(self):
"""Print Current Dot Color"""
print("Dot color is: " + self.color)