Java Java Data Structures Efficiency! Building the Model

javac: file not found: Karaoke.java nothing works

I know this has already been answered here https://teamtreehouse.com/community/javac-file-not-found-karaokejava, but the solution didn't work for me :/ It doesn't matter where I drop Karaoke.java (com or teamtreehouse folder) it doesn't work either way. Here's my snapshot... I'd be grateful for a helping hand in this... https://w.trhou.se/fof8eoogfn

1 Answer

Hello Lena4592,

I'm looking through your code now and found a couple of mistakes. I added comments to help you out. Otherwise, you did great! Keep up the work!

Hope this helps!

SONG.JAVA

package com.treehouse.model; // Not the correct package 'teamtreehouse'

public class Song {
  private String mArtist;
  private String mTitle;
  private String mVideoUrl;

  public Song(String artist, String title, String videoUrl) {
    mArtist = artist;
    mTitle = title;
    mVideoUrl = videoUrl;
  }

  public String getTitle() {
    return mTitle;
  }

  public String getArtist() {
    return mArtist;
  }

  public String gerVideoUrl() {
    return mVideoUrl;  
  }

  @Override
  public String toString() {
    return String.format("Song: %s by %s", mTitle, mArtist);
  }

}

SONGBOOK.JAVA

package com.teamtreehouse.model;

import java.util.List;
import java.util.ArrayList;

public class SongBook {
  private List<Song> mSongs;

  public SongBook() {
    mSongs = new ArrayList<Song>();
  }

  public void addSong(Song song) {
    mSongs.add(song);
  }

  public int getSongCount() {
    return mSongs.size();
  }  
}

KARAOKE.JAVA

import com.teamtreehouse.model.Song;
import com.teamtreehouse.model.Songbook; // Remember to camal case. Java is a case sensitive language. Look at your SongBook.java file name. 

public class Karaoke {

  public static void main(String[] args) {
    Song song = new Song(
      "Michael Jackson",
      "Beat It",
      "https://www.youtube.com/watch?v=tA9kkQFIzvU");
    SongBook songBook = new SongBook();
    System.out.printf("Adding %s %n", song);
    songBook.addSong(song);
    System..out.printf("There are %d songs. %n", songBook.getSongCount());
  }
}

Thank you so much Xavier! I have not noticed that! Everything works beautifully now :)