0

For an assignment I have to create a song/playlist organising program.

The song/playlist have the obvious members + constructors & getters/setters, and the driver reads from 2 files & creates an array of songs, and an array of playlists. (I can't use arraylist).

My question is in regards to some additional functionality i have to provide, such as sorting the songs by title, searching the songs, etc. Where should I be putting these methods?

I'm thinking it should either be a static method of the song class, or perhaps in a separate SongUtils class (and a PlaylistUtils class). Or should i just do it in the driver?

What do you guys think?

Amir
  • 2,082
  • 4
  • 22
  • 28

2 Answers2

1

What I can think of:

  • Have Song class to create your song objects.
  • Have Playlist class that contain your array of songs.
  • Your Main class should have your song list and playlist list (that means array of songs and array of playlists)
  • If you want functionality to sort/search IN A CERTAIN PLAYLIST, then write the method in the Playlist class.
  • If you want functionality to sort/search FROM ALL YOUR SONGS/PLAYLIST, then write the method in the Main class.

This is just a suggestion :) Hope it helps :D

CodingBird
  • 705
  • 2
  • 11
  • 22
  • Thanks for the ideas :) I was doing something similar until now. However, I think Ziv's idea is good so I'm going to try that. – Amir Oct 23 '13 at 09:28
1

I would suggest you to create a dedicated class such as Songs or SongCollection which holds a collection of songs and can manage them in a way of exposing a proper API for the user.

This class can expose methods such as sortListByComparator and this method would get a different Comparator object as a parameter and will sort the collection according to it.

I hope that will help as a start...

Good luck buddy!

Ziv Levy
  • 1,904
  • 2
  • 21
  • 32