why i still receive these errors
this code gives me the following errors,
why?
--------------------Configuration: <Default>--------------------
D:\javafiles\Image Matching Algorithm\ImageMatchingAlgorithm2.java:107: cannot find symbol
symbol : variable getDimX
location: class SubWindow2
System.out.println("sw.getDimX ="+sw.getDimX+" "+"sw.getDimY ="+sw.getDimY);
^
D:\javafiles\Image Matching Algorithm\ImageMatchingAlgorithm2.java:107: cannot find symbol
symbol : variable getDimY
location: class SubWindow2
System.out.println("sw.getDimX ="+sw.getDimX+" "+"sw.getDimY ="+sw.getDimY);
^
D:\javafiles\Image Matching Algorithm\ImageMatchingAlgorithm2.java:108: cannot find symbol
symbol : variable getDimX
location: class SubWindow2
System.out.println("sw.getDimX ="+sw.getDimX+" "+"sw.getDimY ="+sw.getDimY);
^
D:\javafiles\Image Matching Algorithm\ImageMatchingAlgorithm2.java:108: cannot find symbol
symbol : variable getDimY
location: class SubWindow2
System.out.println("sw.getDimX ="+sw.getDimX+" "+"sw.getDimY ="+sw.getDimY);
^
4 errors
Process completed.
Code java:
import java.util.*;
import java.lang.*;
public class ImageMatchingAlgorithm2
{
int swaped1;
int swaped2;
int isolated;
public boolean hasReversed(int mw_axis, int sw_axis)
{
if(sw_axis > mw_axis)
return true;
return false;
}
public boolean isTangible (int mw_axis, int sw_axis)
{
if (mw_axis == sw_axis)
return true;
return false;
}
public void doIsolate(int mw_axis)
{
isolated=mw_axis-1;
}
public int getIsolated()
{
return isolated;
}
public void doSwap(int coor1, int coor2)
{
swaped1=coor2;
swaped2=coor1;
}
public int getMWSwapedDim()
{
return swaped1;
}
public int getSWSwapedDim()
{
return swaped2;
}
public static void main (String[] args)
{
int scanx;
int scany;
Scanner readDim = new Scanner(System.in);
MainWindow2 mw = new MainWindow2();
SubWindow2 sw = new SubWindow2();
ImageMatchingAlgorithm2 Obj = new ImageMatchingAlgorithm2();
int [] CorrlationMatrix=new int [sw.correlationSize()];
System.out.print("Dimension of MW X axis:");
scanx=readDim.nextInt();
mw.setDimX(scanx);
System.out.print("Dimension of MW Y axis:");
scany=readDim.nextInt();
mw.setDimY(scany);
System.out.print("Dimension of SW X axis:");
scanx=readDim.nextInt();
sw.setDimX(scanx);
System.out.print("Dimension of SW Y axis:");
scany=readDim.nextInt();
sw.setDimY(scany);
if (Obj.hasReversed(mw.getDimX(), sw.getDimX()) )
{
Obj.doSwap(mw.getDimX(), sw.getDimX());
mw.setDimX(Obj.getMWSwapedDim());
sw.setDimX(Obj.getSWSwapedDim());
}
if (Obj.isTangible(mw.getDimX(), sw.getDimX()))
{
Obj.doIsolate(mw.getDimX());
sw.setDimX(Obj.getIsolated());
}
if (Obj.hasReversed(mw.getDimY(), sw.getDimY()) )
{
Obj.doSwap(mw.getDimY(), sw.getDimY());
mw.setDimY(Obj.getMWSwapedDim());
sw.setDimY(Obj.getSWSwapedDim());
}
if (Obj.isTangible(mw.getDimY(), sw.getDimY()))
{
Obj.doIsolate(mw.getDimY());
sw.setDimY(Obj.getIsolated());
}
int [][]MainGrid = mw.setPixelValues( mw.defGrid(mw.getDimX(),mw.getDimY()) );
int [][]SubGrid = sw.setPixelValues( sw.defGrid(sw.getDimX(),sw.getDimY()) );
mw.display();
sw.display();
//for(int i=0;i<t.length;i++)
// for (int j=0;j<t[0].length;j++)
sw.initCoor(MainGrid);
System.out.println("sw.getDimX ="+sw.getDimX+" "+"sw.getDimY ="+sw.getDimY);
System.out.println("sw.getDimX ="+sw.getDimX+" "+"sw.getDimY ="+sw.getDimY);
//System.out.println(r);
System.out.println();
System.out.println();
/*do{
int sum=0;
int rounds=0;
for(int i=sw.getCoorX0();i<((sw.swDimx-1)+sw.getCoorX0());i++)
{
for (int j=sw.getCoorY0();j<((sw.swDimy-1)+sw.getCoorY0());j++)
{
sum+=MainGrid[i][j];
}
}
CorrlationMatrix[rounds]=sum;
rounds++;
if (sw.HasVerticalOverLap())
{
sw.Vertical_Shift();
sw.CarryBack();
}
sw.Horizontal_Shift();
System.out.print(sum+" ");
}while(!sw.notDone()); */
//System.out.print("\n"+sw.initCoor()+"\n");
//System.out.println(mw.getDimX()+" "+mw.getDimY());
//System.out.println(sw.getDimX()+" "+sw.getDimY());
}
}
Re: why i still receive these errors
First of all, have a look at the below points:
1) Use when you post your code.
2) Don't create new threads for same problems. You were supposed to post these errors on your previous thread only.
Now, coming back to your errors, they are the same. Even after clearly mentioning your errors, you are not accessing the methods in the right way.
sw.getDimX is accessing variable named getDimX [which doesn't exist in your code].
sw.getDimX() is accessing method named getDimX(). [Notice the bracket ().]
So either declare the variables getDimX and getDimY or access the methods in right way.
Please check the solution provided here
Hope thats clear!
Goldest
Re: why i still receive these errors
thank you for your help
it works now.
and sorry for being unfamiliar with the forum rules
Re: why i still receive these errors
1-would you please give me a simplified example of Encapsulation and Ploymorphism?
2-either both of the fore-mentioned techniques were applied in my java code" the one you corrected to me"??
Re: why i still receive these errors
There are so many reference sites providing the information about java's OOPS concepts. You can refer to any of them.
For now, these are the two links which I find useful for starters.
For Polymorphism : Click here
For Encapsulation : Click here
Hope that helps!
Goldest
Re: why i still receive these errors
And I have deliberately not commented on your second point above,
2-either both of the fore-mentioned techniques were applied in my java code" the one you corrected to me"??
Because I want you to find it out on your own. After reading good documentation about OOPS, you will be surely able to find that out.
Best of luck! :-bd
Goldest
Re: why i still receive these errors
thank you
i'm trying to find out
Re: why i still receive these errors
You are Welcome and let us know when you find it out. :)