I have the following code in a method in a .java file. The method is called scaleUp and takes a Picture object and returns another picture object. I'm trying to invoke or call on this method in a new .java file but I'm not sure how to do so:
This is what I've tried so far:Code:Picture scaleUp(int numTimes)
{
Picture targetPicture =
new Picture(this.getWidth() * numTimes,
this.getHeight() * numTimes);
Pixel sourcePixel = null;
Pixel targetPixel = null;
int targetX = 0;
int targetY = 0;
for (int sourceX = 0;
sourceX < this.getWidth();
sourceX++)
{
for (int sourceY=0;
sourceY < this.getHeight();
sourceY++)
{
sourcePixel = this.getPixel(sourceX,sourceY);
for (int indexY = 0; indexY < numTimes; indexY++)
{
for (int indexX = 0; indexX < numTimes; indexX++)
{
targetX = sourceX * numTimes + indexX;
targetY = sourceY * numTimes + indexY;
targetPixel = targetPicture.getPixel(targetX,
targetY);
targetPixel.setColor(sourcePixel.getColor());
}
}
}
}
return targetPicture;
}
}
I know you have to somehow use an object (picture in this case) to call on the method but I'm pretty lost.Code:public class Lab7
{
public static void main(String[] args)
{
int numTimes;
String fileName = FileChooser.pickAFile();
Picture somePic = new Picture(fileName);
somePic = somePic.scaleUp(numTimes);
}
public Picture scaleUp(int numTimes)
{
this.scaleUp(numTimes);
return //some value
}
}

