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

You have been hired to model one part of the interface for a new machine called

ID: 3755741 • Letter: Y

Question

You have been hired to model one part of the interface for a new machine called “DVD RENTAL MACHINE”. This machine is based on the ATM concept, but instead of giving out money, the DVD RENTAL MACHINE (DRM) dispenses movies. Unlike ATMs, DRMs have 2 display screens: a dialogue screen and a video display screen. These machines are located outside businesses, like Walmart or Publix, that are not typically in the DVD rental business.

There are several different dialogues that the user and the DVD RENTAL MACHINE engage in (e.g., SWIPING the credit card and authorizing it; returning DVDs; physically removing the DVD from the DRM; confirming the selection; etc.). YOU ARE NOT INTERESTED IN ANY OF THESE DIALOGUES. Your task is to model ONLY the DVD Selection Tool of the DVD RENTAL MACHINE. The DVD Selection Tool is available on the DRM 24/7 and is the initial screen on the DRM. The user communicates with the DVD Selection Tool by using a keypad that contains the digits: 1 – 4 and various keys: SCROLL-UP key; SCROLL-DOWN key, SELECT, PREVIEW, RENT, and CANCEL.

The DVD Selection Tool screen first presents a list of movie types and asks the user which type of movie they would they like to VIEW? The VIEW options are:

New releases – choose 1;

Drama – choose 2;

Comedy – choose 3; OR

All Movies – choose 4.

The user enters his/her choice on the keypad. This brings up a display of available movies of that type (see example dialogue on next page.) The top movie in the display is initially highlighted. The user can SCROLL_DOWN () or SCROLL-UP () through the display using the appropriate keys to highlight the next movie in the list.

To SELECT a movie, the user presses SELECT, which displays the front and back of the highlighted movie’s DVD package, including a description of the movie, in the DVD Display Screen. To PREVIEW a movie the user presses the PREVIEW key that plays a short preview of the highlighted movie in the DVD Display Screen. To RENT the highlighted movie the user presses the RENT key and that closes the DVD Selection Tool and brings up a confirmation dialogue. Alternatively, there is a CANCEL button that closes all dialogues and brings back up the DVD Selection Tool initial screen.

A sample display follows:

Assume the user selected 1: for New Releases. The following is displayed:

Star Trek

World War Z

Oblivion

Gatsby

Iron Man 3

SCROLL_DOWN () results in World War Z being highlighted: World War Z

From here, the user may SELECT, PREVIEW, or RENT the movie World War Z OR choose to move through the list, or CANCEL to return back to the DVD Selection Tool initial screen.

Define the DVD Selection Tool as an ADT. Include the headers for FOUR of the operations, as well as pre- and post conditions, and comments describing each operation.

Explanation / Answer

public class Library {
private ArrayList<Book> allBook = new ArrayList<Book>();

public Library(ArrayList<Book> other) {
if (other == null) {
throw new NullPointerException("null pointer");
} else
this.allBook = other;
}

public Library() {
this.allBook = new ArrayList<Book>();
}

public boolean add(Book book) {
if (book != null && !book.equals("")) {
throw new IllegalArgumentException("Can't be empty");
}
allBook.add(book);
return true;
}

public ArrayList<Book> findTitles(String title) {
for(Book b: allBook) {
if(title.compareTo(b.getTitle())== 0) {
return allBook;
}
}
return null;
}

public void sort() {
Collections.sort(allBook);
}

public String toString() {
return Library.this.toString();
}
}

public class Book implements Comparable<Book> {
private String bookTitle;
private ArrayList<String> bookAuthor;

public Book(String title, ArrayList<String> authors) {
if(title == null && authors == null) {
throw new IllegalArgumentException("Can't be null");
}
if(title.isEmpty() && authors.isEmpty()) {
throw new IllegalArgumentException("Can't be empty");
}
bookTitle = title;
bookAuthor = authors;
}

public String getTitle() {
return bookTitle;
}
public ArrayList<String> getAuthors( ) {
return bookAuthor;
}

public String toString( ) {
return bookTitle + bookAuthor;
}
public int compareTo(Book other){
return bookTitle.compareTo(other.bookTitle);
}
public boolean equals(Object o) {
if(!(o instanceof Book)) {
return false;
}
Book b = (Book) o;
return b.bookTitle.equals(bookTitle)
&& b.bookAuthor.equals(bookAuthor);
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote