[android-developers] Method oddly not working, help needed.
Here is my method for part of a calculator app, could someone take a
look and see why it isnt working?(PS is parenthases start while PE is
end)
Boolean solve2( int min, int max){
int x = min-1;
while(x<max)
{
x++;
Cursor note = mDbHelper.fetchNote(x);
if(Boolean.parseBoolean(note.getString(note.getColumnIndexOrThrow(NotesDbAdapter.KEY_ISPS))))
{
int y = x;
boolean z = false;
while(y<max && z==false){
y++;
Cursor note1 = mDbHelper.fetchNote(y);
if(Boolean.parseBoolean(note1.getString(note.getColumnIndexOrThrow(NotesDbAdapter.KEY_ISPE))))
{z = true;}
}
solve1(x,y);
max-=(y-x);
}}
int xa = min-1;
while(xa<max)
{
xa++;
Cursor note2 = mDbHelper.fetchNote(xa);
if(Boolean.parseBoolean(note2.getString(note2.getColumnIndexOrThrow(NotesDbAdapter.KEY_ISPOWER))))
{
int ya = xa+1;
int za = xa-1;
Cursor note3 = mDbHelper.fetchNote(ya);
Cursor note4 = mDbHelper.fetchNote(za);
double n =
Double.valueOf(note3.getString(note3.getColumnIndexOrThrow(NotesDbAdapter.KEY_VALUE)));
double m =
Double.valueOf(note4.getString(note4.getColumnIndexOrThrow(NotesDbAdapter.KEY_VALUE)));
double g = Math.pow(n,m);
double da = g;
mDbHelper.updateNote(da, false, false, false, false, false, false, 0,
za, false, false);
mDbHelper.deleteNote(xa);
mDbHelper.deleteNote(xa);
max -=2;
}
if(Boolean.parseBoolean(note2.getString(note2.getColumnIndexOrThrow(NotesDbAdapter.KEY_ISROOT))))
{
int aya = xa+1;
int aza = xa-1;
Cursor anote3 = mDbHelper.fetchNote(aya);
Cursor anote4 = mDbHelper.fetchNote(aza);
double an =
Double.valueOf(anote3.getString(anote3.getColumnIndexOrThrow(NotesDbAdapter.KEY_VALUE)));
double am =
Double.valueOf(anote4.getString(anote4.getColumnIndexOrThrow(NotesDbAdapter.KEY_VALUE)));
double ag = Math.pow(an,1/am);
double ada = ag;
mDbHelper.updateNote(ada, false, false, false, false, false, false,
0, aza, false, false);
mDbHelper.deleteNote(xa);
mDbHelper.deleteNote(xa);
max -=2;
}
}
int xb = min-1;
while(xb<max)
{
xb++;
Cursor note2 = mDbHelper.fetchNote(xb);
if(Boolean.parseBoolean(note2.getString(note2.getColumnIndexOrThrow(NotesDbAdapter.KEY_ISMULTIPLIER))))
{
int yb = xb+1;
int zb = xb-1;
Cursor note3 = mDbHelper.fetchNote(yb);
Cursor note4 = mDbHelper.fetchNote(zb);
double n =
Double.valueOf(note3.getString(note3.getColumnIndexOrThrow(NotesDbAdapter.KEY_VALUE)));
double m =
Double.valueOf(note4.getString(note4.getColumnIndexOrThrow(NotesDbAdapter.KEY_VALUE)));
double g = n*m;
double db = g;
mDbHelper.updateNote(db, false, false, false, false, false, false, 0,
zb, false, false);
mDbHelper.deleteNote(xb);
mDbHelper.deleteNote(xb);
max -=2;
}
if(Boolean.parseBoolean(note2.getString(note2.getColumnIndexOrThrow(NotesDbAdapter.KEY_ISDIVISOR))))
{
int ya = xb+1;
int za = xb-1;
Cursor note3 = mDbHelper.fetchNote(ya);
Cursor note4 = mDbHelper.fetchNote(za);
double n =
Double.valueOf(note3.getString(note3.getColumnIndexOrThrow(NotesDbAdapter.KEY_VALUE)));
double m =
Double.valueOf(note4.getString(note4.getColumnIndexOrThrow(NotesDbAdapter.KEY_VALUE)));
double g = n/m;
double da = g;
mDbHelper.updateNote(da, false, false, false, false, false, false, 0,
za, false, false);
mDbHelper.deleteNote(xb);
mDbHelper.deleteNote(xb);
max -=2;
}
}
int xc = min-1;
while(xc<max)
{
xc++;
Cursor note2 = mDbHelper.fetchNote(xc);
if(Boolean.parseBoolean(note2.getString(note2.getColumnIndexOrThrow(NotesDbAdapter.KEY_ISADD))))
{
int yb = xc+1;
int zb = xc-1;
Cursor note3 = mDbHelper.fetchNote(yb);
Cursor note4 = mDbHelper.fetchNote(zb);
double n =
Double.valueOf(note3.getString(note3.getColumnIndexOrThrow(NotesDbAdapter.KEY_VALUE)));
double m =
Double.valueOf(note4.getString(note4.getColumnIndexOrThrow(NotesDbAdapter.KEY_VALUE)));
double g = n*m;
double db = g;
mDbHelper.updateNote(db, false, false, false, false, false, false, 0,
zb, false, false);
mDbHelper.deleteNote(xc);
mDbHelper.deleteNote(xc);
max -=2;
}
if(Boolean.parseBoolean(note2.getString(note2.getColumnIndexOrThrow(NotesDbAdapter.KEY_ISSUBTRACT))))
{
int ya = xc+1;
int za = xc-1;
Cursor note3 = mDbHelper.fetchNote(ya);
Cursor note4 = mDbHelper.fetchNote(za);
double n =
Double.valueOf(note3.getString(note3.getColumnIndexOrThrow(NotesDbAdapter.KEY_VALUE)));
double m =
Double.valueOf(note4.getString(note4.getColumnIndexOrThrow(NotesDbAdapter.KEY_VALUE)));
double g = n/m;
double da = g;
mDbHelper.updateNote(da, false, false, false, false, false, false, 0,
za, false, false);
mDbHelper.deleteNote(xc);
mDbHelper.deleteNote(xc);
max -=2;
}
}
if(min==max)
{return true;}
else{return false;}}
Solve 1 is identical except it uses Solve 2 in the paranthasees
portion.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home