FlashMath – You do the math

After some hours of coding, a new App was published in the Market. You can find it here. This app challenges kids to do math even faster. It requires some settings (max values, types of questions) and then it’s good to go. Coding-wise, not much new stuff in here. I used smart layouting for Landscape / Portrait optimalization.

CaptureJust define layouts for all the seperate elements and later, include them in a master layout (<include layout=”@layout/calculator_frame” />) in your Layout-Port folder. Now, define a different layout for your Landscape-mode and place it in the Layout-Land folder. That’s it!

As for the Settings (Preferences), I really should get down to studying the newly introduced, fragment-style settings. I just used the old (deprecated) methods for now.

There is one nice piece of could I would like to highligt. Each time the user answers a question correctly, the time (ms) is stored in an ArrayList. Later, this list is used to calculate a mean time. Now, for adding more fun while crunching the numbers, I wanted to introduce a motivating message when the user does better than he or she did before. But, obviously, the app could’ve just presented a series of very easy questions, rendering this new found ‘level of mathism’ quite useless. So, I decided to weigh the average time against the three most recent average time scores.. That way, the motivational quote would only appear if real progress was made. If that level is held or if the user falls back, the good old “speed up a bit” will be shown. I used this code :

	public void handleMeanTimes(int meantime) {
		if (ArrayMeanTimes.size() < 4) {
			ArrayMeanTimes.add(meantime);
			StatusMessage = getString(R.string.status_you_can_do_it);
		} else {
			Log.v(TAG, "Let's remove item at 0...");
			ArrayMeanTimes.remove(0);
			ArrayMeanTimes.add(meantime);
			int calc = 0;
			for (int i = 0; i < ArrayMeanTimes.size(); i++) {
				calc = calc + ArrayMeanTimes.get(i);
				Log.v(TAG, "Item at " + i + " = " + ArrayMeanTimes.get(i));
			}
			int toBeat = calc / 4;
			Log.v(TAG, "Item to Beat : " + toBeat);
			if (meantime < toBeat) {
				StatusMessage = getString(R.string.status_great_work);
			} else {
				StatusMessage = getString(R.string.status_speed_up);
			}
		}
	}

For other parts of the application, I used technologies I already was familiar with. For instance, the sound is played by SoundPool. This is a technique you can review in this post.

All suggestions for this app are welcome! I can’t wait to implement them ;). As far as the Goal goes, I now have a steady income of about 1/24th of what I need. So… Not quite there yet 😉

You can leave a response, or trackback from your own site.

Leave a Reply