Skip to content

Instantly share code, notes, and snippets.

@antony-jr
Created September 21, 2020 04:24
Show Gist options
  • Save antony-jr/7087a489ac9cd368ccc1a080ef7188b3 to your computer and use it in GitHub Desktop.
Save antony-jr/7087a489ac9cd368ccc1a080ef7188b3 to your computer and use it in GitHub Desktop.
import java.util.HashMap;
public class Music {
private HashMap<String, Object> m_Data;
public Music() {
m_Data = new HashMap<String, Object>();
}
public void set(String key, Object value) {
m_Data.put(key, value);
}
public Object get(String key) {
return get(key);
}
public String toString() {
String out = "";
for (HashMap.Entry<String, Object> entry : m_Data.entrySet()) {
String key = entry.getKey();
Object value = entry.getValue();
out += key + ": " + value.toString() + "\n";
}
return out;
}
public static void main(String[] args){
Music meta = new Music();
meta.set("Artist", "Demi Lovato");
meta.set("Album", "Confident");
meta.set("Title", "Stone Cold");
meta.set("Genre", "Pop");
meta.set("Year", 2017);
meta.set("Track Number", 1);
meta.set("Duration", 4.05);
System.out.println(meta);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment