Constructor with unknown amount of objects?
Ok, as a project for my programming class i was given te job to create a Point class then creating a circle class and then making a drawing class. This drawing class would consist of multiple circle objects that would then be stored in an array. To be honest i am utterly at a road block as to how make this constructor. i have tried...
Code:
import java.util.Scanner;
public class Dessin {
Scanner scan = new Scanner(System.in);
int i;
public Dessin(int size)
{
Cercle[] tab = new Cercle[size];
for (i=0;i<tab.length;i++);
{
double x=scan.nextDouble(); double y=scan.nextDouble(); double z=scan.nextDouble();
tab[i]=new Cercle(x,y,z);
}
}
No doubt this thinking is VERY flawed, i believe that my Dessin constructor should receive a circle(x coordinates, its y and its radius), and maybe a double to say how many to make.
I am up for any suggestions on ways to do this constructor, this is a learning experience so any input on better way of doing things would be appreciated. Thank you