Welcome to the CSC Q&A.
Get help and give help!
Write great code!
It is our choices... that show what we truly are, far more than our abilities.

Categories

+5 votes
asked in CSC201 Spring 2021 by (8 points)

1 Answer

+4 votes

We only use the term constructor to refer to the special init method that is creating a new object of the specific class that we are defining.

Other methods may involve code that creates things, but that doesn't make them constructors.

In the case of the draw method, it actually isn't creating any new objects -- it's merely changing the visual representation of what appears within a window.

If we do:

myCircle = Circle(Point(100,100),50)

that is what calls the Circle's constructor method, and creates the new Circle object. When we do

myCircle.draw(window)

That doesn't create a Circle... the Circle already existed as an object in the computer's memory (in the same way that string objects exist, even if we don't PRINT them!) This just makes the Circle object visible.

answered by (2.9k points)
...