Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: gatesphere/445-assignment3
base: fa80889d50
...
head fork: gatesphere/445-assignment3
compare: bd0734e6f8
Checking mergeability… Don't worry, you can still create the pull request.
  • 4 commits
  • 1 file changed
  • 0 commit comments
  • 2 contributors
Showing with 45 additions and 0 deletions.
  1. +45 −0 src/Node.java
View
45 src/Node.java
@@ -0,0 +1,45 @@
+import java.io.ObjectInputStream;
+import java.io.FileInputStream;
+import java.io.ObjectOutputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.HashMap;
+
+public class Node implements Serializable {
+
+ private static final String FILENAME = "data";
+
+ protected HashMap<Integer, MusicObject> data;
+
+
+ public Node() {
+ this.data = new HashMap<Integer, MusicObject>();
+ }
+
+ public void addMusicObject(MusicObject song) {
+ this.data.put(song.getId(), song);
+ }
+
+ protected void writeToFile() {
+ try {
+ FileOutputStream fos = new FileOutputStream(FILENAME);
+ ObjectOutputStream oos = new ObjectOutputStream(fos);
+
+ oos.write(this.data);
+
+ oos.close();
+ } catch (IOException e) { e.printStackTrace(); }
+ }
+
+ protected void readFromFile() {
+ try {
+ FileInputStream fis = new FileInputStream(FILENAME);
+ ObjectInputStream ois = new ObjectInputStream(fis);
+
+ this.data = (HashMap<Integer, MusicObject>)ois.read(data);
+
+ ois.close();
+ } catch (IOException e) { e.printStackTrace(); }
+ }
+}

No commit comments for this range

Something went wrong with that request. Please try again.