For some java homework we were told to create a program that makes collages, with one of the methods being that the one of the "fragments"(images) of the collage will be scaled by width and height. The pre-written class "fragment" already has a method to scale the image:
public void scaleFragment(int newWidth, int newHeight)
{
width = newWidth;
height = newHeight;
}
So in the main class I call up this method by doing this:
public void makeTiles(int tileWidth, int tileHeight)
{
for (Fragment sm:collage){
Fragment.scaleFragment(tileWidth, tileHeight);
}
}
When I try to run this however, I come up with this error:
"non-static method scaleFragment (int,int) cannot be referencd from a static context"
After reading up on this website I found that you needed to crate an instance of the class?so I did this:
Fragment fragment = new Fragment();
for (Fragment sm:collage){
Fragment.scaleFragment(tileWidth, tileHeight);
}
This however comes up with the error "constuctor error in class fragment cannot be applied to given types"
The main class has declaces the arraylist collage like this:
Fragment fragment = new Fragment();
for (Fragment sm:collage){
Fragment.scaleFragment(tileWidth, tileHeight);
}
can anyone help me solve this problem?
Thanks in advance.