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 trialScott Chaplinski
6,542 Points3 resets and my workspace is still completely blank. Can someone please post the starter code unedited for me?
I've deleted the workspace and re-opened it 3 different times.
3 Answers
gmilan
9,287 PointsYou can go to workspaces click settings and delete your workspace. Then reload a new workspace from the video your working in.
Scott Chaplinski
6,542 PointsJust tried it for a third time, no dice.
gmilan
9,287 Pointsimport java.util.Arrays;
import java.util.Date;
import com.teamtreehouse.Treet;
import com.teamtreehouse.Treets;
public class Example {
public static void main(String[] args) {
Treet treet = new Treet(
"Craigsdennis",
"Yo what up.",
new Date(1421810125));
Treet secondTreet = new Treet (
"jouneytocode",
"@treehouse makes learning Java sooo fun! #treet",
new Date(1421878767000L));
System.out.printf("This is a new Treet: %s%n", treet);
System.out.println("The words are:");
for(String word: treet.getWord()) {
System.out.println(word);
}
Treet[] treets = {treet, secondTreet};
Arrays.sort(treets);
for (Treet exampleTreet : treets) {
System.out.println(exampleTreet);
}
Treets.save(treets);
Treet[] reloadedTreets = Treets.load();
for (Treet reloaded : reloadedTreets) {
System.out.println(reloaded);
}
}
}
gmilan
9,287 Pointspackage com.teamtreehouse;
import java.io.*;
public class Treets {
public static void save(Treet[] treets) {
try (
FileOutputStream fos = new FileOutputStream("treets.ser");
ObjectOutputStream oos = new ObjectOutputStream(fos);
) {
oos.writeObject(treets);
} catch(IOException ioe) {
System.out.println("Promblem saving Treets.");
ioe.printStackTrace();
}
}
gmilan
9,287 Pointspackage com.teamtreehouse;
import java.io.Serializable;
import java.util.Date;
public class Treet implements Comparable, Serializable {
private static final long serialVersionUID = 8344377823118097712L;
private boolean mBreakIt = true;
private String mAuthor;
private String mDescription;
private Date mCreationDate;
public Treet(String author, String description, Date creationDate) {
mAuthor = author;
mDescription = description;
mCreationDate = creationDate;
}
@Override
public String toString() {
return String.format("Treet: \"%s\" by %s on %s",
mDescription, mAuthor, mCreationDate);
}
@Override
public int compareTo(Object obj) {
Treet other = (Treet) obj;
if(equals(other)) {
return 0;
}
int dateCmp = mCreationDate.compareTo(other.mCreationDate);
if (dateCmp == 0) {
return mDescription.compareTo(other.mDescription);
}
return dateCmp;
}
public String getAuthor() {
return mAuthor;
}
public String getDescription() {
return mDescription;
}
public Date getCreationDate() {
return mCreationDate;
}
public String[] getWord() {
return mDescription.toLowerCase().split("[^\\w#@']+");
}
}
gmilan
9,287 PointsDid you go to home page next to your points is the workspace icon you click that, then next to the workspace you want to delete you click the gear symbol and delete.
Scott Chaplinski
6,542 PointsYeah I did that several times. thank you for the code!