Working on my first Android app, Cat Calculator. Calculations work fine after the cat is purring, but if it wants catnip or fancy feast petting it again reaches the debug error from the final "Else" statement instead of the cat biting or ignoring you.
Providing full code, but the error is likely in the last 10 lines...
Appreciate any help you can provide. -Michael
/** Called when the user clicks the CatCalculator button */
public void doCalculation(View view) {
TextView homeAnswerView = (TextView) findViewById(R.id.homeAnswerView);
TextView catActivityView = (TextView) findViewById(R.id.catActivityView);
Random randomcatmood = new Random();
double catmood = randomcatmood.nextDouble();
if (catActivityView.getText().equals("cat calculator is sleeping on calculator")) {
if (catmood <= 0.33) {
catActivityView.setText("cat calculator starts purring");
} else if (catmood <= 0.66) {
catActivityView.setText("cat calculator wants fancy feast");
} else {
catActivityView.setText("cat calculator wants a catnip toy");
}
} else if (catActivityView.getText().equals("cat calculator starts purring")) {
int answerInt;
String answer;
EditText numberOne = (EditText) findViewById(R.id.number1);
EditText numberTwo = (EditText) findViewById(R.id.number2);
int numberOnee = Integer.parseInt(numberOne.getText().toString());
int numberTwoo = Integer.parseInt(numberTwo.getText().toString());
answerInt = numberOnee * numberTwoo;
answer = Integer.toString(answerInt);
homeAnswerView.setText(answer);
} else if (catActivityView.equals("cat calculator wants fancy feast")) {
catActivityView.setText("cat calculator bites you for petting it now!");
} else if (catActivityView.equals("cat calculator wants a catnip toy")) {
catActivityView.setText("cat calculator bites you for petting it now!");
} else if (catActivityView.equals("cat calculator bites you for petting it now!")) {
catActivityView.setText("cat calculator ignores you");
} else if (catActivityView.equals("cat calculator ignores you")) {
} else {
catActivityView.setText("debug: this should never happen");
}
}