Saturday, October 13, 2012

[Android] Random Generator of a String in a String Array


When I came to live to this country, I tried to convince myself to not eat the same things all over again. There are many places/options available, so Why would I end going to McD’s again? Yes, junk food is inevitable in this country; and when a person gets in the boring cycle of routine, he/she will eventually end eating in the first restaurant that gets available. Sometimes the place will be healthy, and sometimes it won’t; but the thing is that we, “humans”, are creatures of habit. Eventually, we are going to get comfortable around the things that were unacceptable once.

Nowadays, it is really easy to find a restaurant to eat. There are many apps available in multiple platforms that will help people to find these places. For example, using several conditions, Urbanspoon (Android, Blackberry, iOS) will help the user to find the right one. Nevertheless, because we are creatures of habit (there are other conditions that apply of course: willing to drive to a far place, amount of time, money available, special occasion, etc.), we are going to end in the same restaurants over and over again.

Here is when my girlfriend appears. She, as everyone else, has her own tastes, but the problem is that I like everything; (Sometimes, I see myself as the starving goat from an old Tex Avery cartoon; --> Billy Boy) and, we don’t easily agree to eat in any of our favorite restaurants. In that precise moment, Java came to help :) and with the assistance of a String[] and a random generator, the problem was solved. (Yes, you are right; McDonald’s is inside of the array).

Here is the code:

Some screenshots of the app in action:





No comments:

Post a Comment