Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java Java Data Structures - Retired 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 :)