Question: Create a JUnit test suite and test runner for the DVD Collection Project. The rest of the prompt is screenshotted below. Both DVD . java

Create a JUnit test suite and test runner for the DVD Collection Project. The rest of the prompt is screenshotted below. Both DVD.java and DVDCollection.java classes are also screenshotted below. The DVDConsoleUI.java class is written out here below.
Please fully complete this Java JUnit test project and create source files for all classes, tests, test suite, and the test runner. Also provide screenshots of the test runs and results.
DVDConsoleUI.java:
import java.util.*;
/**
* This class is an implementation of DVDUserInterface
* that uses the console to display the menu of command choices
*/
public class DVDConsoleUI implements DVDUserInterface {
private DVDCollection dvdlist;
private Scanner scan;
public DVDConsoleUI(DVDCollection dl){
dvdlist = dl;
scan = new Scanner(System.in);
}
public void processCommands()
{
String[] commands ={"Add/Modify DVD",
"Remove DVD",
"Get DVDs By Rating",
"Get Total Running Time",
"Save and Exit"};
int choice;
do {
for (int i =0; i commands.length; i++){
System.out.println("Select "+ i +": "+ commands[i]);
}
try {
choice = scan.nextInt();
scan.nextLine();
switch (choice){
case 0: doAddOrModifyDVD(); break;
case 1: doRemoveDVD(); break;
case 2: doGetDVDsByRating(); break;
case 3: doGetTotalRunningTime(); break;
case 4: doSave(); break;
default: System.out.println("INVALID CHOICE - TRY AGAIN");
}
} catch (InputMismatchException e){
System.out.println("INVALID CHOICE - TRY AGAIN");
scan.nextLine();
choice =-1;
}
} while (choice != commands.length-1);
}
private void doAddOrModifyDVD(){
// Request the title
System.out.println("Enter title");
String title = scan.nextLine();
if (title.equals("")){
return; // input was cancelled
}
title = title.toUpperCase();
// Request the rating
System.out.println("Enter rating");
String rating = scan.nextLine();
if (rating.equals("")){
return; // input was cancelled
}
rating = rating.toUpperCase();
// Request the running time
System.out.println("Enter running time");
String time = scan.nextLine(); // NOTE: time read in as a String!
if (time.equals("")){
return; // input was cancelled
}
// Add or modify the DVD (assuming the rating and time are valid)
dvdlist.addOrModifyDVD(title, rating, time);
// Display current collection to the console for debugging
System.out.println("Adding/Modifying: "+ title +","+ rating +","+ time);
System.out.println(dvdlist);
}
private void doRemoveDVD(){
// Request the title
System.out.println("Enter title");
String title = scan.nextLine();
if (title.equals("")){
return; // dialog was cancelled
}
title = title.toUpperCase();
// Remove the matching DVD if found
dvdlist.removeDVD(title);
// Display current collection to the console for debugging
System.out.println("Removing: "+ title);
System.out.println(dvdlist);
}
private void doGetDVDsByRating(){
// Request the rating
System.out.println("Enter rating");
String rating = scan.nextLine();
if (rating.equals("")){
return; // dialog was cancelled
}
rating = rating.toUpperCase();
String results = dvdlist.getDVDsByRating(rating);
System.out.println("DVDs with rating "+ rating);
System.out.println(results);
}
private void doGetTotalRunningTime(){
int total = dvdlist.getTotalRunningTime();
System.out.println("Total Running Time of DVDs: ");
System.out.println(total);
}
private void doSave(){
dvdlist.save();
}
}
DVDManager.java:
public class DVDManager {
public static void main(String[] args){
DVDCollection dl = new DVDCollection();
// Always use the GUI interface
// Removes all command console output
DVDUserInterface dlInterface = new DVDGUI(dl);
dlInterface.processCommands();
}
}
DVDUserInterface.java:
public interface DVDUserInterface
{
void processCommands();
}
Create a JUnit test suite and test runner for the

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!