You can have this printed for the final
Make classes:
- name instance variables
- use instance variables as this.variable name
- encapsulate with private (fence off anyone of another class from ever using these directly)
- create constructors: public methodname (type var, type var){ }
- constructors are special methods with no return type and methodname the same as the class name
- methods using "this" are not static
- static means the method cannot use instance variables (cuts off "this")
- public [static] returnType methodname (type var, type var){ }
Use classes
- Instances: Scanner, Point, DecimalFormatter, Random, plus classes you create
- Fully Static classes: Math
- Create instances using constructor:
- classname variable = new classname(var, var);
- Call methods of an instance:
- variable = object identifier.methodname(var, var);
- if the method is not static, you cannot call it from [class ], you must use [object identifier].
Arrays
- One element (value) per index
- index starts at 0
- Create array variable type with type[ ] variable_name
- Fill with a new array with variable_name = new type[ size ]
- Access element with variable_name [ index ];
- get length with variable_name.length;
public static return_type method_name (type parm1, type parm2)
{
...
...
return expression;
}
To set up fang:
import fang2.core.*;
import fang2.sprites.*;
import java.awt.*;
import java.awt.geom.*;Your class must extend GameLoop ex: public class Wackadot extends GameLoop
Steps to add shapes to the panel:
@Override
public void startGame()