Question: Implement a video manager. You can add videos, create playlists, generate HTML for playlists, etc. In the code distribution we have included a driver (SampleDriver.java)
Implement a video manager. You can add videos, create playlists, generate HTML for playlists, etc. In the code distribution we have included a driver (SampleDriver.java) and expected output (SampleDriverOutput.txt) that illustrates some of the functionality provided by the system. We recommend you take a look at it so you get a sense of what you need to implement.
Fill in the empty methods to add videos, create playlist and generate HTML for playlist in Playlist.Java and also Video.Java
- tubeVideosManager A package where you will find shells for classes you need to implement.
- tests A package where you will find public tests and a shell file for student tests.
- text files/directories Files providing input for public tests, and support directories will be found in the main project folder. Expected outputs for public tests will be found in the expectedResults folder. Results generated by your code when you run your public tests will be placed in the results folder.
Method Descriptions are below
Genre.java
public enum Genre { Comedy, Educational, Documentary, Music, FilmAnimation }
Playlist.java
import java.util.ArrayList;
public class Playlist { private String name; private ArrayList videoTitles;
* Initializes playlist with the specified name and creates an empty ArrayList. If the parameter is null or is a blank string (according to String class isBlank() method) the method will throw an IllegalArgumentException (with any message) and perform no processing.*/ public Playlist(String name) { } * Get method for name */ public String getName() { } * Initializes the current object so changes to the current object will not affect the parameter object.*/ public Playlist(Playlist playlist) { } * Provided; please don't modify. toString for class */ public String toString() { String answer = "Playlist Name: " + name + " ";
answer += "VideoTitles: " + videoTitles;
return answer; } * Adds the title to the Arraylist storing titles. We can add the same video title several times. If the parameter is null or is a blank string (according to String class isBlank() method) the method will throw an IllegalArgumentException (with any message) and perform no processing. */ public boolean addToPlaylist(String videoTitle) { }
/** * Get method for the ArrayList of titles. You must avoid privacy leaks. * * @return ArrayList with titles */ public ArrayList getPlaylistVideosTitles() { throw new UnsupportedOperationException("Implement this method"); } * Removes all instances of the title parameter from the ArrayList of titles. If the parameter is null or is a blank string (according to String class isBlank() method) the method will throw an IllegalArgumentException (with any message) and perform no processing.@param videoTitle @return true if the ArrayList (videoTitles) was changed as a result of calling this method and false otherwise.*/ public boolean removeFromPlaylistAll(String videoTitle) { } * Randomizes the list of titles using a random parameter and Collections.shuffle. If the parameter is null, call Collections.shuffle with just the ArrayList.*/ public void shuffleVideoTitles(Random random) { } }
TubeVideosManager.java
Video.java
import java.util.ArrayList;
public class Video implements Comparable
{ private String title, url; private int durationInMinutes; private Genre videoGenre; private ArrayList comments;
* Initializes a video object. If any parameter is null or if a string parameter is a blank (according to String class isBlank() method), the method will throw an IllegalArgumentException (with any message) and perform no processing. Also the same exception will be thrown if the duration is zero or negative.*/ public Video(String title, String url, int durationInMinutes, Genre videoGenre) { } * Initializes the Video object so changes to the parameter do not affect the current object. Your implementation must be efficient (avoid any unnecessary copies).* public Video(Video video) { } * Get method for title* public String getTitle() { } * Get method for url*/ public String getUrl() { throw new UnsupportedOperationException("Implement this method"); } * Get method for duration */ public int getDurationInMinutes() { } * Get method for video genre*/ public Genre getGenre() { }
public String toString() { String answer = "Title: " + "\"" + title + "\" ";
answer += "Url: " + url + " "; answer += "Duration (minutes): " + durationInMinutes + " "; answer += "Genre: " + videoGenre + " ";
return answer; } * Adds specified comments to the video. If the parameter is null or is a blank string (according to String class isBlank() method) the method will throw an IllegalArgumentException (with any message) and perform no processing. @param comments @return true if comments added; false otherwise */ public boolean addComments(String comments) { } * Returns copy so changes to the copy does not affect the original. Your implementation must be efficient (avoid any unnecessary copies). @return ArrayList of strings public ArrayList getComments() { } * Videos will be compared using title. If we were to sort an ArrayList of Videos, they will appear in lexicographical (alphabetical) order (e.g, "A","B", "C").@return negative, 0, or positive value public int compareTo(Video video) { } * Two Video objects are considered equal if they have the same title. Implement the method using the instanceof operator rather than using getClass(). @return true if objects are considered equal; false otherwise @Override public boolean equals(Object obj) { } }
TubeVideosManagerInt.java is an interface for TubeVideosManager.
import java.io.*;
public interface TubeVideosManagerInt {
public boolean addVideoToDB(String title, String url, int durationInMinutes, Genre videoGenre);
public ArrayList
getAllVideosInDB();
public Video findVideo(String title);
public boolean addComments(String title, String comments);
public boolean addPlaylist(String playlistName);
public String[] getPlaylistsNames();
public boolean addVideoToPlaylist(String title, String playlistName);
public Playlist getPlaylist(String playlistName);
public void clearDatabase();
public Playlist searchForVideos(String playlistName, String title, int maximumDurationInMinutes, Genre genre);
public boolean loadVideosToDBFromFile(String filename, boolean printFeedback);
public String getStats();
public void genHTMLForPlaylist(String filename, String playlistName, boolean printFeedback); }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
