Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I am looking for a java program that will allow for a user to enter Media type(s

ID: 667411 • Letter: I

Question

I am looking for a java program that will allow for a user to enter Media type(song or video), title, author, album, genre and filename in a single input. Store all the information in a class called description. Also, there needs to be a class called library where these are used:

public boolean add(MediaDescription aClip);

public boolean remove(String aTitle);

public MediaDescription get(String aTitle);

public String[] getTitles();

public String[] getMusicTitles();

public String[] getVideoTitles();

Explanation / Answer

MediaDescription :

public class MediaDescription
{
  
   static enum AlbumType
   {
       SONG,VIDEO
   }
  
   private String title, author, album, genre, filename;
   private AlbumType type;
   public MediaDescription(AlbumType t, String title, String author, String album,String genre, String filename)
   {
       this.type = t;
       this.setTitle(title);
       this.setAuthor(author);
       this.setAlbum(album);
       this.setGenre(genre);
       this.setFilename(filename);
   }

   public String getTitle() {
       return title;
   }

   public String getAuthor() {
       return author;
   }

   public String getAlbum() {
       return album;
   }

   public String getGenre() {
       return genre;
   }

   public String getFilename() {
       return filename;
   }

   public void setTitle(String title) {
       this.title = title;
   }

   public void setAuthor(String author) {
       this.author = author;
   }

   public void setAlbum(String album) {
       this.album = album;
   }

   public void setGenre(String genre) {
       this.genre = genre;
   }

   public void setFilename(String filename) {
       this.filename = filename;
   }

   public AlbumType getType() {
       return type;
   }

   public void setType(AlbumType type) {
       this.type = type;
   }
  
  
}

//#########################################################################################

Library :

import java.util.ArrayList;

public class Library {
   MediaDescription[] media;
   int size;

   public Library() {
       media = new MediaDescription[50];
       size = 0;
   }

   public boolean add(MediaDescription aClip) {
       media[size] = aClip;
       size++;

       return true;
   }

   public boolean remove(String aTitle) {
       for (int i = 0; i < size; i++) {
           if (aTitle.equals(media[i].getTitle())) {
               // remove it
               media[i] = media[size];
               size--;
               return true;
           }
       }

       return false;
   }

   public MediaDescription get(String aTitle) {
       for (int i = 0; i < size; i++) {
           if (aTitle.equals(media[i].getTitle())) {
               return media[i];
           }
       }

       return null;
   }

   public String[] getTitles() {
       String[] titles = new String[size];

       for (int i = 0; i < size; i++) {
           titles[i] = media[i].getTitle();
       }
       return titles;
   }

   public String[] getMusicTitles() {
       ArrayList<String> musicTitles = new ArrayList<String>();

       for (int i = 0; i < size; i++) {
           if (media[i].getType() == MediaDescription.AlbumType.SONG) {
               musicTitles.add(media[i].getTitle());
           }
       }
       return (String[]) musicTitles.toArray();
   }

   public String[] getVideoTitles() {
       ArrayList<String> videoTitles = new ArrayList<String>();

       for (int i = 0; i < size; i++) {
           if (media[i].getType() == MediaDescription.AlbumType.VIDEO) {
               videoTitles.add(media[i].getTitle());
           }
       }
       return (String[]) videoTitles.toArray();
   }
}