Question: Create a program in java that reads media objects such as books.java, music.java, and video.java( I have already created those files). Implement my own HashMap
Create a program in java that reads media objects such as books.java, music.java, and video.java( I have already created those files). Implement my own HashMap implementation. I may not use java.util.HashMap or java.util.TreMap. After it reads the media objects, it stores the media objects into my HashMap implementation using the unique ID as a key to the map(not an arraylist). It then prints the media objects from the HashMap in a friendly fashion. I may use iterator or for-each loop and do not just system.out.prinln the hashmap but iterate through it.
I need to create a program that reads in the Media objects(books,music,video) that I have attached. It will read it from a text file that those 3 files created which is also attached. I need to correctly create an appropriate HashMap that handles media objects such as below(books,music,video) without the use of java.util.HashMap or java.util.TreeMap . After HashMap reads the media objects, I want it to store the media objects into the hashmap that was just created and using the unique ID as the key to the map. Then print out the media objects from the HashMap.
Attached are the files I have created.
public class Book extends Media { private String format; private String author; private String isbnNumber; public Book(int idNumber, String itemName, String type, String format, String author, String isbnNum) { super(idNumber, itemName, type); this.format = format; this.author = author; this.isbnNumber = isbnNum; } public String getFormat() { return format; } public String getAuthor() { return author; } public String getIsbnNumber() { return isbnNumber; } @Override public String toString() { return super.toString() + " Book [format=" + format + ", author=" + author + "]"; } } Media File
public class Media { private int idNumber; private String itemName; private String type; public Media(int idNumber, String itemName, String type) { this.idNumber = idNumber; this.itemName = itemName; this.type = type; } public int getIdNumber() { return idNumber; } public String getItemName() { return itemName; } @Override public String toString() { return "Media [idNumber=" + idNumber + ", itemName=" + itemName + ", type=" + type + "]"; } public String getType() { return type; } } Music File
public class Music extends Media { private String format; private String artist; public Music(int idNumber, String itemName, String type, String format, String artist) { super(idNumber, itemName, type); this.format = format; this.artist = artist; } @Override public String toString() { return super.toString() + " Music [format=" + format + ", artist=" + artist + "]"; } public String getFormat() { return format; } public String getArtist() { return artist; } } Video File
public class Video extends Media { private String definition; private String format; private String director; private String rating; private String genre; public String getDefinition() { return definition; } public String getDirector() { return director; } public String getRating() { return rating; } public String getGenre() { return genre; } @Override public String toString() { return super.toString() + " Video [definition=" + definition + ", format=" + format + ", director=" + director + ", rating=" + rating + ", genre=" + genre + "]"; } public String getFormat() { return format; } public Video(int idNumber, String itemName, String type, String definition, String format, String director, String rating, String genre) { super(idNumber, itemName, type); this.definition = definition; this.format = format; this.director = director; this.rating = rating; this.genre = genre; } } Text file it reads from
video Star Wars 2 high definition DVD George Lucas science fiction PG book Object-Oriented Programming 3 Dr. Java Expert digital ISBN1 music Star Wars Soundtrack 3 John Williams CD video Empire Strikes Back 4 high definition DVD George Lucas science fiction PG book Object-Oriented Requirements Analysis 5 Dr. Java Expert print ISBN2 music Empire Soundtrack 6 John Williams digital book mybook 7 me ebook 1234565677
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
