I have five classes. My Main class, a form class, two subclasses that extend the form class and a createForm class I am forced to use to create new instances of the subclass.
public class FormenFabrik {
public Form createForm(String newform) {
if(newform.equals("Kreis")) {
Form newKreis = new Kreis();
return newKreis;
}else{
Form newRechteck = new Rechteck();
return newRechteck;
}
}
}
We're forced to use public Form createForm(String string){} as our method.
We're supposed to pass a String to the method and depending on what form we pass over ("Circle" or "Rectangle"), the method returns either a new Circle or a new Rectangle.
But I can't figure out how to call that method from my Main class.
createForm()be a static method or non-static method?