Java Reference
In-Depth Information
So our main plugin class, so far, would look like this:
Then there's the
CreeperCowTimer
, which will hold a cow and take care of the
things an attacking cow needs to do:
Notice we haven't gotten into any detail of particular functions yet: you want
to get a firm idea in your head of
why
a particular class needs to exist. What
is it responsible for doing?
For each responsibility, take a stab at working out what it needs to do. So as
not to get too hung up on Java syntax and issues (or those of any other pro-
gramming language, for that matter), say what you want to do in plain English.
Tell the story of
what
you want to do—don't worry about
how
yet.
Each step will become a function, or
multiple functions
if you decide to split
the step into a couple of simpler functions and/or classes.
1.
Create our list of cows.
2.
Spawn creeper cows and add them to our list.
3.
Set up each creeper cow with a timer.
4.
Listen for events to create and remove cows.