Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java program. I need help I try it but won't work for me .... can I do it without adding any new methods?? 1. Option

Java program.

I need help I try it but won't work for me .... can I do it without adding any new methods??

1. Option 2 is insert a new Movie after the Movie that is currently playing. So, will this option work when watchlist is empty, since current movie in empty watchlist is not set 2. If current movie is last movie in the watchlist and if we remove that, then will the new current movie become the 1st movie in the watchlist? 3. How we find the 1st and last movie in the watchlist?

==============================

Use the following steps to create a program that allows the user to manipulate a movie watchlist and view it. Your program should contain 3 separate classes: a Movie class, a Watchlist class, and a Demo class. In this program, the Watchlist class will function as a doubly linked list that contains Movie objects. The Demo class will be used to make modifications to the Watchlist.

  1. Create a Movie class. This class should contain the following attributes:
    1. String name
    2. String year
    3. String genre
    4. int length
    5. Movie next
    6. Movie previous

The Movie class should contain the appropriate getters and setters for these attributes, a no-arg constructor, and a constructor that accepts the following arguments: name, year released, genre, and length in hours.

  1. Create a Watch list class. This class will act as our doubly linked list. This class should contain the following attributes:
    1. Movie head (a blank movie object that will represent the first movie in the watchlist)
    2. Movie tail (blank movie object that will represent the last movie in the watchlist)
    3. int size (integer to hold the number of movies in the watch list)
    4. int length (integer to hold the duration of the watchlist in hours)

The Watch list class should contain a no-arg constructor which initializes the size, length, head and tail attributes. This no-arg constructor should also properly connect the head and tail nodes of the doubly linked list.

The Watch list class should also contain the following methods:

  1. A method that accepts a Movie object and adds it to the end of the Watchlist.
  2. A method that accepts 2 Watch list objects (a new Movie to be added, and a movie that is currently playing from the watchlist). This method will insert the new Movie into the watchlist at the position directly after the Movie that is currently playing.
  3. A method that accepts a Movie object, returns nothing, and removes the Movie from the watchlist.
  4. A toString method that prints out the contents of the Watchlist. This toString method should also calculate and display the number of movies in the watchlist, as well as the length of the watchlist in hours.

  1. Create a Demo class that will serve to accept user input and manipulate the Watchlist doubly linked list. The Demo class should instantiate a Watchlist object and allow for the following actions:

  1. Add a Movie to the Watchlist
  2. Insert a new Movie after the Movie that is currently playing.
  1. If a movie is being added/inserted to an empty watchlist, that movie should then be set to be the first one to be played.
  1. Print the contents of the Watchlist.
  2. Display the current Movie.
    1. When displaying the current movie for the first time, the first movie in the watchlist should be displayed.
  3. Remove the current movie.
    1. When removing the current movie, the new current movie will be the movie that directly follows the removed movie.
  4. Skip to the next movie
    1. If you are at the end of the Watchlist, the next Movie should be the first Movie in the watchlist.
  5. Return to the previous movie.
    1. If you are at the beginning of the Watchlist, the previous Movie should be the last Movie in the watchlist.
  6. Exit

If any of the options chosen would not work due to there being no applicable movies in the watchlist, that message should be noted. The user should be allowed to select menu options until they choose to Exit. Validate the users input for a menu option. The user should be required to enter a valid menu option before advancing.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Microsoft SQL Server 2012 Administration

Authors: Adam Jorgensen, Steven Wort

1st Edition

1118106881, 9781118106884

More Books

Students also viewed these Databases questions

Question

How does co-op advertising differ from tactical marketing?

Answered: 1 week ago