Coding the Apple class
Let's start with the Apple class as we often do by adding the required import statements and the member variables. Add the code and study it and then we will discuss it:
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Point;
import java.util.Random;
class Apple {
// The location of the apple on the grid
// Not in pixels
private Point mLocation = new Point();
// The range of values we can choose from
// to spawn an apple
private Point mSpawnRange;
private int mSize;
// An image to represent the apple
private Bitmap mBitmapApple;
}
The Apple class has a Point object that we will use to store the horizontal...