Create
a
constructor
for
Die( singular dice as in one)
that
takes
one
argument,
an
int
representing
the
number
of
sides.
If the number is less than 2, store 6 as the number of sides in the class field.
Other-
wise, store the number given.
package die;
public class Die {
private int sides;
Die(int n){
if(n<2){
sides = 6;
}
else{
sides = n;
}
}
public static void main(String[] args) {
}
}
Comments
Leave a comment