Currently I have a project that can statically create objects of a class:
Song song1 = new Song();
song1.setTitle("Paint it Black");
song1.setRating(4);
song1.setPrice(0.99);
Song song2 = new Song("Hey Jude",4.99);
song2.setRating(10);
This works just fine, but I would like to make it so that i can create objects without having to hard code each and every object into my program, because as you can imagine it can get lengthy. Is there a way I can achieve this?
Essentially, instead of
Song song1 = new Song();
Song song2 = new Song();
Song song3 = new Song();
Song song4 = new Song();
Song song5 = new Song();
...
Song songN = new Song();
Have a single algorithm to create my objects (song1, song2, song3, ... songN) for me based on user input
List<Song>, but you'll need a lot more clarity in your question in terms of what your'e trying to achieve.Songwill hold, like title, artist, and so on. So you need some source of that data. You can ask user to fill these information each time you run your code, or you could read them from some file.