Classes contain methods
Classes contain the code for methods that act on objects; methods have access to the object using the special variable "this".
We'll cover the following...
We'll cover the following...
Here is some code to create a custom Ball class that is used to store information about a ball that will bounce on the screen. The main method of BallExample creates a Ball object using the new keyword and a call to the constructor. Read the code carefully now:
The BallExample class also has a method drawBall that accesses instance variables of the Ball object and uses them, together with a Canvas object to draw a circle in the right place on the screen.
Classes group together methods. It seems like the code for drawBall might naturally be in the Ball class. Like this:
The BallExample class ...