Assigning parameter as array length

Posted by Jcolnz on Stack Overflow See other posts from Stack Overflow or by Jcolnz
Published on 2013-10-24T03:48:26Z Indexed on 2013/10/24 3:54 UTC
Read the original article Hit count: 95

Filed under:
|
|

I am currently stuck with a homework assignment, question below;

Define a default constructor for Deck that initialises the deck field with an array of size 0. Also define a constructor that takes an integer parameter and initialises the deck field with an array of that size. The constructor should also initialise every element with a new random MovieCard. The cards should be uniquely named.

so far my code is

public class Deck {

    MovieCard[] deck = new MovieCard[] {};

    public Deck() {

        MovieCard deck[];

    }

    public Deck(int size) {

        MovieCard deck = new MovieCard[];


    }

}

Obviously this is incomplete by I can't find any references in my previous notes about referring a parameter into an array and setting this as the length.

© Stack Overflow or respective owner

Related posts about java

Related posts about arrays