title: Moving objects from one class to another (Java)
body: <p>just wondering how I would go about creating a playlist of song objects (song1, song2, song3, song4) where each object has it's own values (name, artist, filesize, duration). I am not able to use arrays/lists for this program. Just look at the <code>getSong()</code> and <code>addSongToPlaylist()</code> methods below, I included the other methods just to show the structure of the song objects.</p>
  
  <p>This is my SongDatabase class:</p>
  
  <pre><code>public class SongDatabase {
      Scanner console = new Scanner(System.in);  
      private Song song1=null, song2=null, song3=null, song4=null;
  
  public void addNewSong() {         
      if (song1 == null) { 
          song1 = getFromUser(); 
      }
      else if (song2 == null) { 
          song2 = getFromUser(); 
      }    
      else if (song3 == null) { 
          song3 = getFromUser(); 
      }
      else if (song4 == null) { 
          song4 = getFromUser(); 
      }
      else {
          System.out.println("The database is currently full. Please delete a song before adding a new one."); 
          System.out.println("");
      }    
  }
  
  private Song getFromUser() { 
      Song song = new Song(); 
  
      System.out.println("Name of song:"); 
      song.setName(console.next()); 
  
      System.out.println("Artist:"); 
      song.setArtist(console.next()); 
  
      System.out.println("File size (MB):"); 
      song.setFileSize(console.nextInt()); 
  
      System.out.println("Duration (seconds):"); 
      song.setDuration(console.nextInt()); 
  
      System.out.println("Song successfully added."); /
      System.out.println("");
  
      return song; 
  }
  
  public Song getSong(int songNumber) { 
      if (songNumber == 1){ 
          return song1; 
      }
      else if (songNumber == 2){ 
          return song2; 
      }
      else if (songNumber == 3){ 
          return song3; 
      }
      else if (songNumber == 4){ 
          return song4; 
      }
  
      else {
          return song1; 
      }
  }
  </code></pre>
  
  <p>And then my menu class:</p>
  
  <pre><code>public class Menu {
  
      Scanner console = new Scanner(System.in); 
      private SongDatabase database = new SongDatabase(); 
      private Playlist playlist = new Playlist(); 
      private int songCount=0; 
  
  private void addSongToPlaylist() { 
    if (songCount &lt;=3) { 
  
      System.out.println("Please enter the number of the song you'd like to be added to the playlist."); 
      System.out.println("");
  
      int songNumber; 
      songNumber = console.nextInt(); 
  
      switch (songNumber) { 
          case 1:
              playlist.setSong(database.getSong(1)); 
              break;
          case 2:
              playlist.setSong(database.getSong(2)); 
              break;
          case 3:
              playlist.setSong(database.getSong(3)); 
              break;
          case 4:
              playlist.setSong(database.getSong(4)); 
              break;
          default:
              System.out.println("Please enter a valid song number."); 
              break;
      }
      songCount++; 
    }
  </code></pre>
  
  <p>So far, the <code>addSongToPlaylist()</code> method should get the song1 object from the <code>getSong()</code> method right? But I am unsure how to add these song objects into a playlist in the <code>Playlist</code> class. I know I need a method like <code>public void setSong(parameters?)</code> but I am unsure how to structure it. Any ideas? Help would be greatly appreciated, thanks!</p>