Game Development Reference
In-Depth Information
package invincibagel;
public class CastingDirector {
private List<Actor> CURRENT_CAST = new ArrayList<>();
public List<Actor> getCurrentCast() {
return CURRENT_CAST ;
}
}
As you can see in Figure 10-3 , there is wavy red error highlighting under your List
interface reference as well as your ArrayList reference in the line of code that declares
and instantiates the CURRENT_CAST object, so you'll need to use the Alt-Enter
work process, and have NetBeans 8 write the import java.util.List; state-
ment at the top of your class. The .getCurrentCast() will be the easiest method to
code, as it simply returns your entire CURRENT_CAST ArrayList<Actor> object to
whatever Java entity may be calling the method. Next, we'll take a look at how to code
the more complicated ArrayList data store access methods, which will deal with
adding, removing, and resetting (clearing) the Actor objects from this
CURRENT_CAST ArrayList<Actor> object.
Figure 10-3 . Inside the CastingDirector class, add a CURRENT_CAST List<Actor> object, and a .getCurrentCast()
method
The first method that we will code is the .addCurrentCast() method, which will
pass in a comma delimited List of Actor objects to the List (and the ArrayList class that
implements List) interfaces .addAll() method call. As you have learned already, a
 
 
Search WWH ::




Custom Search