How would I dynamically select a certain Object depending on user input then use other Methods to alter that particular Object?
<p>Hi I'm currently writing a Virtual Pet style app, I have created a Class for the base of the pets called Pet.class </p>

<pre><code>    package com.grim.droidchi;

public class Pet {

    public static int Health = 100;
    public static int Happiness = 10;
    public static int Level = 1;
    public static int Hunger = 0;
    public static int Exp = 0;
    public static String Name;
    public static Boolean isAlive = true;
    public static Boolean isSick = false;

    public Pet(int startHealth, int startLevel, int startHunger) {

    }

   }
</code></pre>

<p>And a 'Dog' class which extends the base pet class</p>

<pre><code>package com.grim.droidchi;


public class Dog extends Pet {

    public Dog(int startHealth, int startLevel, int startHunger) {
        super(startHealth, startLevel, startHunger);

    }

}
</code></pre>

<p>every 30 minutes An AlarmManager triggers my Gameloop.class </p>

<pre><code>package com.grim.droidchi;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.media.MediaPlayer;
import android.util.Log;
import android.widget.TextView;

public class Gameloop extends BroadcastReceiver {
    MediaPlayer mp = null;
    private static final String TAG = "VPET";

    @Override
    public void onReceive(Context context, Intent intent) {
        Log.d(TAG, "Loop running");
        if (Pet.isAlive == true) {
            Pet.Hunger = Pet.Hunger + 1;
            Pet.Exp = Pet.Exp + 2;
            Pet.Happiness = Pet.Happiness - 1;

            mp = MediaPlayer.create(context, R.raw.beep);
            mp.start();
            petLevel();
            petStatus();
            randomEncounters();
        } else {

        }
    }

    private void petLevel() {


    }

    private void randomEncounters() {
        if (Math.random() &lt; 0.20) {
            Pet.isSick = true; 

        }

    }

    private void petStatus() {
        if (Pet.Hunger &gt; 7) {
            Pet.isAlive = false;

        } 

    }

}
</code></pre>

<p>How do I get what's done in the Gameloop to be dependent on which particular pet the user decides to pick? (Assuming I create more pet types. )</p>

<p>P.S Also as a siden ote to this question, What is the best way to implement keeping the UI always up-to-date from the Gameloop class?</p>

<p>Any help will be appreciated. I am still learning about Java and Android sometimes its hard to find a specific/question answer even a midst of all good learning materials.</p>

<p>Thank you.</p>
