Okay, so I've completed 99% of an assignment for university, however, I want to know how I can cram a lot into one method, I want to know how I can nicely return a lot of values from one method, so it can be processed in another.
So I currently have many methods that make shapes, but each one for each individual shape, however all shapes share similar variables, they only differ in terms of height/width, and they do differ in and order too, etc.
i.e.:
// shape 1 constructor
shape1(var1, var2, var3, var 4, var 5);
shape2( var4, var5, var6, var1, var2, var3);
An example would be something like :
private static Shape1 createShape1(Scanner in){
var1 = in.nextInt();
var2 = in.nextInt();
var3 = in.nextInt();
var4 = in.nextInt();
var5 = in.nextInt();
// you get the picture
Shape1 myShape1 = new Shape1 (var1, var2, var3, var4, var5);
return myShape1 ;
}
Well I've done this many times, in many different methods, however I can't help but feel this is not a nice way to do things. So I was wondering, can I put all this in one method, that way this method can be called from any other method, I need an individual method for each individual shape, it's the way my lecturer has set things up. I was thinking on something more like allowing the above shape1 method to call this other method. Then pass the method it has called into a shape1 constructor, as I have another class that allows you to create a custom hexagon. But the constructor in the hex class requires the values that's being passed into the scanner. But I also want to be able to pass this other method into shape2's method and constructor?