If I have a constructor called Point inside class Point:
public Point(double x, double y) {
this.x = x;
this.y = y;
}
How can I use it another class called Square and initialize the points. For example, I want to initialize 4 points in a square. How can I do that?
I don’t know if that makes sense. But, I tried my best… ask me questions so that I can explain better.
If you want to have a
Squarewith for points, make them attributes:Of course, there are a zillion other ways of defining and using this. It will depend primarily on your class / program design what you should choose.