Created
September 21, 2020 04:24
-
-
Save antony-jr/7087a489ac9cd368ccc1a080ef7188b3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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