Help!, cant find method

Dear all,

I cant figure out what the problem is, if anyone has any clues I would be eternally grateful :P

//http://www.dickbaldwin.com/java/Java028.htm

//http://java.sun.com/docs/books/tutorial/java/nutsandbolts/arrays.html

//http://en.wiktionary.org/wiki/Wiktionary:English_inflection

//http://java.sun.com/developer/J2METechTips/2002/tt0131.html

import javax.microedition.midlet.*;

import javax.microedition.lcdui.*;

import java.io.*;

import javax.microedition.io.*;

public class HoroscopesMidlet2 extends MIDlet implements

CommandListener {

private Display display;

private Command exit;

private Command enter;

public TextField month;

public TextField day;

private Form form;

//star sign variables

int beginDay;

int beginMonth;

String name;

// returns horoscope name

public String getName() { return name; }

public HoroscopesMidlet2(int bd, int bm, String nm) {

//star sign variable assignments

beginDay= bd;

beginMonth = bm;

name = nm;

//month = new TextField ("Month","",10,TextField.NUMERIC);

//day = new TextField ("Day","",10,TextField.NUMERIC);

form = new Form ("Horoscopes");

exit = new Command ("Exit", Command.CANCEL,2);

enter = new Command ("Enter", Command.OK,2);

}

public void startApp() {

display = Display.getDisplay(this);

form.append(month);

form.append(day);

form.addCommand(exit);

form.addCommand(enter);

form.setCommandListener(this);

display.setCurrent(form);

}

public void pauseApp() {

}

public void destroyApp(boolean unconditional) {

notifyDestroyed();

}

class Horoscope {

HoroscopesMidlet2[] signs;

public Horoscope() {

signs = new HoroscopesMidlet2[12];

signs[0] = new HoroscopesMidlet2(22, 12, "Capricorn");

signs[1] = new HoroscopesMidlet2(21, 1, "Aquarius");

signs[2] = new HoroscopesMidlet2(20, 2, "Pisces");

signs[3] = new HoroscopesMidlet2(21, 3, "Aries");

signs[4] = new HoroscopesMidlet2(21, 4, "Taurus");

signs[5] = new HoroscopesMidlet2(22, 5, "Gemini");

signs[6] = new HoroscopesMidlet2(22, 6, "Cancer");

signs[7] = new HoroscopesMidlet2(24, 7, "Leo");

signs[8] = new HoroscopesMidlet2(24, 8, "Virgo");

signs[9] = new HoroscopesMidlet2(24, 9, "Libra");

signs[10] = new HoroscopesMidlet2(24, 10, "Scorpio");

signs[11] = new HoroscopesMidlet2(23, 11, "Sagitarius");

}

HoroscopesMidlet2 findSign(int day, int mth) {

if (mth < 1 || mth > 12)

return null;

if (mth == 12) {

if (day >= signs[0].beginDay && day < 32)

return signs[0];

else

if (day > 31 || day < 1 )

return null;

else

return signs[11];

}

if (mth == 1) {

if (day >= signs[1].beginDay && day < 32)

return signs[1];

else

if (day > 31 || day < 1 )

return null;

else

return signs[0];

}

if (mth == 2) {

if (day >= signs[2].beginDay && day < 29 )

return signs[2];

else

if (day > 28 || day < 1 )

return null;

else

return signs[1];

}

if (mth == 3) {

if (day >= signs[3].beginDay && day < 32)

return signs[3];

else

if (day > 31 || day < 1 )

return null;

else

return signs[2];

}

if (mth == 4) {

if (day >= signs[4].beginDay && day < 31)

return signs[4];

else

if (day > 30 || day < 1 )

return null;

else

return signs[3];

}

if (mth == 5) {

if (day >= signs[5].beginDay && day < 32)

return signs[5];

else

if (day > 31 || day < 1 )

return null;

else

return signs[4];

}

if (mth == 6) {

if (day >= signs[6].beginDay && day < 31)

return signs[6];

else

if (day > 30 || day < 1 )

return null;

else

return signs[5];

}

if (mth == 7) {

if (day >= signs[7].beginDay && day < 32)

return signs[7];

else

if (day > 31 || day < 1 )

return null;

else

return signs[6];

}

if (mth == 8) {

if (day >= signs[8].beginDay && day < 32)

return signs[8];

else

if (day > 31 || day < 1 )

return null;

else

return signs[7];

}

if (mth == 9) {

if (day >= signs[9].beginDay && day < 31)

return signs[9];

else

if (day > 30 || day < 1 )

return null;

else

return signs[8];

}

if (mth == 10) {

if (day >= signs[10].beginDay && day < 32)

return signs[10];

else

if (day > 31 || day < 1 )

return null;

else

return signs[9];

}

if (mth == 11) {

if (day >= signs[11].beginDay && day < 31)

return signs[11];

else

if (day > 30 || day < 1)

return null;

else

return signs[10];

} else {

tryAgain();

}

return null;

}

}

public void tryAgain() {

Alert error = new Alert("Date Incorrect", "Please try again", null,

AlertType.ERROR);

error.setTimeout(Alert.FOREVER);

month.setString("");

day.setString("");

display.setCurrent(error, form);

}

public void commandAction(Command c, Displayable d) {

String label = c.getLabel();

if(label.equals("Exit")) {

destroyApp(true);

} else if (label.equals("Enter")) {

int mm = Integer.parseInt(month.getString());

int dd = Integer.parseInt(day.getString());

HoroscopesMidlet2 hscp = findSign(mm, dd);

}

}

}

[6078 byte] By [epoa] at [2007-11-27 2:10:22]
# 1

I cannot find your explanation of what is wrong with your code from your post, neither can I find a specific question.

My answer would be, there for, "It doesn't work."

If you wish a more specific answer, then please post a more specific question and not "please fix my program--here it is."

Also please use code tags when you post next time.

morgalra at 2007-7-12 2:02:19 > top of Java-index,Java Essentials,Java Programming...
# 2

int mm = Integer.parseInt(month.getString());

int dd = Integer.parseInt(day.getString());

Can you catch the NumberFormatException for this?

Can you print a stackTrace?

try{

//problem code

}catch(Exception e){

e.printStackTrace();

}

grizlya at 2007-7-12 2:02:19 > top of Java-index,Java Essentials,Java Programming...
# 3
I now have the problem sorted, the main problem was the findSign method could not be found as it was not declared publically and I was abit mixed up between strings and ints. Many thanks however for taking a look at my problem.
epoa at 2007-7-12 2:02:20 > top of Java-index,Java Essentials,Java Programming...