int[] arrayName = new int[size];
int someVar = arrayName [3];
Classes:
a class is a blueprint (directions) for creating objects
-attributes (data values ; state)
-methods (algorithms to manipulate the data)
overload: multiple methods with the same name
the compiler chooses the right method based on the method signature:
-name
-types of the parameters
-order of the parameters
to create a class:
public class Die {
Maximum value for the die (final meaning we cannot change the max_value anymore)
private final int MAX_VALUE = 6 ;
Value of the die
private int faceValue ;default constructor
sets the initial fce value to 1
public Die (){ faceValue = 1 ; }
constructor with initial face value
public Die (int initialValue){faceValue - initialValue ; }
Roll and the die return the result.
public int roll (){faceValue = ((int) (math.random().MAX_Value)) +1 ;
return (faceValue) ;}