How do I write an add method?

i have been trying to write the code but i can't get it:
getList: a public method that returns an array of Songs and takes no parameters. It returns a deep copy of list. It creates a local array of Songs with the same number of elements as list, copies the elements from list into the local array, and returns the local array.
add: a public method that returns nothing and takes one Song parameter. If the song isn’t already in the play list (determined by calling the inList method described below) then:
A local array of Songs is declared and set to a new array of Songs containing room for the songs in list plus one more Song.
The Songs from list are copied into the local array.
The parameter Song is placed in the extra element.
The local array is assigned to list so that list now points to the new array containing the added Song.
Finally, a message containing the Song followed by " was added to the play list." is printed to the console.
If the parameter Song is already in the play list then a message containing the Song followed by " is already in the play list." is printed to the console.
overo5
Asked Dec 05, 2009
Edited Dec 05, 2009

TIP: If it's not your answer to this question, please click "Leave a Comment" button under the question to communicate with the question owner.

Can you help them?

You may want to know:

Categories