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 trialGhostIn Shell
1,967 PointsCan someone help with importing of com.teamtreehouse.model
The folders in workspace... Java Data Structure then "com" then "teamtreehouse" then "model". I have the two files under model Song.java and SongBook.java. Then there is Karaoke.java which I am assuming is under Java Data Structures. The error is printed below. There are 6 errors but I am assuming those clear when this is cleared. Please help... Thank You.
Karaoke.java:1: error: package com.teamtreehouse.model does not exist
import com.teamtreehouse.model.Song;
^
Karaoke.java:2: error: package com.teamtreehouse.model does not exist
import com.teamtreehouse.model.SongBook;
package com.teamtreehouse.model;
import java.util.ArrayList;
import java.util.List;
public class SongBook {
private List<Song> mSongs;
public SongBook() {
mSong = new ArrayList<Song>();
}
public void addSong(Song song) {
mSongs.add(song);
}
public in getSongCount() {
return mSongs.size();
}
}
package com.teamtreehouse.model;
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 getVideoUrl() {
return videoUrl;
}
@Override
public String toString(){
return String.formate("Song: %s by %s", mTitle, mArtist);
}
}
import com.teamtreehouse.model.Song;
import com.teamtreehouse.model.SongBook;
public class Karaoke {
public static void main(String[] args){
Song song = new Song(
"Michael Jackson",
"Beat It",
"https://www.youtube.com/watch?v=SaEC9i9Q0vk");
SongBook songBook = new SongBook();
System.out.printf("adding %s %n", song);
songBook.addSong(song);
System.out.printf("There are %d songs. %n", songBook.getSongCount());
}
}
1 Answer
GhostIn Shell
1,967 PointsAnswered my own question... I had "Com" instead of "com" as the folder name. All other spelling mistakes corrected.