Question: Required Classes 1. Slide Class public static final int MAX_BULLETS = 5 private String title private String[] bullets private double duration public Slide() Brief :
Required Classes
1. Slide Class
public static final int MAX_BULLETS = 5
private String title
private String[] bullets
private double duration
public Slide()
Brief:
Default constructor.
Postconditions:
This object has been initialized to an empty Slide (title and all bullets are null, duration = 0.0)
Note:
You may create a custom constructor which takes arguments if you wish.
public String getTitle()
Brief:
Public getter method for the title member variable.
Returns:
The title of the Slide.
public void setTitle(String newTitle)
Brief:
Public setter method for the title member variable.
Parameters: newTitle
The new title of this slide. This parameter should not be null
Preconditions:
newTitle is not null.
Throws: IllegalArgumentException
Thrown if newTitle is null.
public double getDuration()
Brief:
Public getter method for the duration member variable.
Returns:
The duration of the Slide.
public void setDuration(double newDuration)
Brief:
Public setter method for the duration member variable.
Parameters: newDuration
The new duration of this slide. This parameter should be greater than 0.
Preconditions:
newDuration is greater than 0.
Throws: IllegalArgumentException
Thrown if newDuration is less than or equal to 0.
public int getNumBullets()
Brief:
Gets the total number of bullet point in the Slide.
Returns:
The number of bullet points in the Slide.
Note:
This method counts the number of non-null elements in the bullets array.
public String getBullet(int i)
Brief:
Gets the bullet point at index i.
Parameters: i
The index to retrieve from the array. This value must be between 1 and MAX_BULLETS, inclusive.
Preconditions:
1 i MAX_BULLETS.
Returns:
The String representing the bullet point at the given index (may be null, meaning there is no bullet point at this index).
Throws: IllegalArgumentException
Thrown if i is not in the valid range.
public void setBullet(String bullet, int i)
Brief:
Sets bullet as the i'th bullet point for bullets. If bullet is null, this method erases the bullet point at index i and pushes all bullet points greater than i back one index (i.e. leaves no holes in the bullets array).
Parameters: bullet
The String to place as the ith bullet point in bullets. This parameter may be null, indicating that the bullet at index i is to be erased from the slide.
i
The index to place bullet in the array. This value must be between 1 and MAX_BULLETS, inclusive.
Preconditions:
1 i MAX_BULLETS.
Postconditions:
The bullet point at index i has been updated to the String bullet.
There are no holes in the bullets array. All bullet points occupy the lowest possible indices of the array.
Throws: IllegalArgumentException
Thrown if i is not in the valid range.
Note:
You may index bullets in this array however you like. If you wish to allocate a String array of size MAX_BULLETS and index starting from 0, this is fine (just remember to subtract 1 from i before setting the bullet point). Conversely, you can also allocate a String array of size MAX_BULLETS + 1 and index from 1, using the 0'th index as a dummy placeholder (you can use i as-is).
2. SlideListNode Class
private Slide data
private SlideListNode next
private SlideListNode prev
public SlideListNode(Slide initData)
Brief:
Default constructor.
Parameters: initData
The data to be wrapped by this SlideListNode. This parameter should not be null, since we should never have a SlideListNode with null data (remember, this class serves only as a wrapper for the Slide class).
Preconditions:
initData is not null.
Postconditions:
This SlideListNode has been initialized to wrap the indicated Slide, and prev and next have been set to null.
Throws: IllegalArgumentException
Thrown if initData is null.
public Slide getData()
Brief:
Gets the reference to the data member variable of the list node.
Returns:
The reference of the data member variable.
public void setData(Slide newData)
Brief:
Updates the data member variable with a reference to a new Slide.
Parameters: newData
Reference to a new Slide object to update the data member variable. This parameter should not be null, since we should never have a SlideListNode with null data (remember, this class serves only as a wrapper for the Slide class).
Preconditions:
newData is not null.
Throws: IllegalArgumentException
Thrown if newData is null.
public SlideListNode getNext()
Brief:
Gets the reference to the next member variable of the list node.
Returns:
The reference of the next member variable. Note that this return value can be null, meaning that there is no next SlideListNode in the list.
public void setNext(SlideListNode newNext)
Brief:
Updates the next member variable with a new SlideListNode reference.
Parameters: newNext
Reference to a new SlideListNode object to update the next member variable. This parameter may be null, since it is okay to have no next SlideListNode (this means weve reached the tail of the list!).
public SlideListNode getPrev()
Brief:
Gets the reference to the prev member variable of the list node.
Returns:
The reference of the prev member variable. Note that this return value can be null, meaning that there is no previous SlideListNode in the list. (this means weve reached the head of the list!).
public void setPrev(SlideListNode newPrev)
Brief:
Updates the prev member variable with a new SlideListNode reference.
Parameters: newPrev
Reference to a new SlideListNode object to update the prev member variable. This parameter may be null, since it is okay to have no previous SlideListNode (this means weve reached the head of the list!).
3. SlideList Class
private SlideListNode head
private SlideListNode tail
private SlideListNode cursor
public SlideList()
Brief:
Default constructor which initializes this object to an empty list of Slides.
Postconditions:
This SlideList has been initialized with head, tail, and cursor all set to null.
public int size()
Brief:
Returns the total number of Slides in the slideshow.
Returns:
The count of all Slides in the slideshow.
Note:
This method should run on O(1) time.
public double duration()
Brief:
Returns the total duration of the slideshow.
Returns:
The sum of all individual Slide durations in the slideshow.
Note:
Depending on the implementation, this method may run in O(1) or O(n) time. both will be accepted..
public int numBullets()
Brief:
Returns the total number of bullet points in the slideshow.
Returns:
The sum of all bullet points of all individual Slides in the slideshow.
Note:
Depending on the implementation, this method may run in O(1) or O(n) time. both will be accepted..
public Slide getCursorSlide()
Brief:
Gets the reference to the Slide wrapped by the SlideListNode currently referenced by cursor.
Returns:
The reference of the Slide wrapped by the SlideListNode currently referenced by cursor. If the cursor is null, then this method should return null as well (i.e. the cursor does not reference a Slide).
public void resetCursorToHead()
Brief:
Returns the cursor to the start of the list.
Postconditions:
If head is not null, the cursor now references the first SlideListNode in this list.
If head is null, the cursor is set to null as well (there are no Slides in this list).
public void cursorForward()
Brief:
Moves the cursor to select the next SlideListNode in the list. If the cursor is at the tail of the list, this method throws an exception (this includes the case where cursor and tailare both null).
Throws: EndOfListException
Thrown if cursor is at the tail of the list.
public void cursorBackward()
Brief:
Moves the cursor to select the previous SlideListNode in the list. If the cursor is at the head of the list, this method throws an exception (this includes the case where cursor and head are both null).
Throws: EndOfListException
Thrown if cursor is at the head of the list.
public void insertBeforeCursor(Slide newSlide)
Brief:
Inserts the indicated Slide before the cursor.
Parameters: newSlide
The Slide object to be wrapped and inserted into the list before the cursor.
Preconditions:
newSlide is not null.
Postconditions:
newSlide has been wrapped in a new SlideListNode object
If cursor was previously not null, the newly created SlideListNode has been inserted into the list before the cursor.
If cursor was previously null, the newly created SlideListNode has been set as the new head of the list (as well as the tail).
The cursor now references the newly created SlideListNode.
Throws: IllegalArgumentException
Thrown if newSlide is null.
Warning
You should NOT move data references around between SlideListNodes to accomplish this method. Instead, you should wrap the newSlide object in a new SlideListNode object, and insert this object into the list before the cursor.
public void appendToTail(Slide newSlide)
Brief:
Inserts the indicated Slide after the tail of the list.
Parameters: newSlide
The Slide object to be wrapped and inserted into the list after the tail of the list.
Preconditions:
newSlide is not null.
Postconditions:
newSlide has been wrapped in a new SlideListNode object
If tail was previously not null, the newly created SlideListNode has been inserted into the list after the tail.
If tail was previously null, the newly created SlideListNode has been set as the new head of the list (as well as the tail).
The tail now references the newly created SlideListNode.
Throws: IllegalArgumentException
Thrown if newSlide is null.
Note:
This insertion method does not affect the cursor, unless the list was previously empty. In that case, head, tail, and cursor should all reference the new SlideListNode.
public Slide removeCursor()
Brief:
Removes the SlideListNode referenced by cursor and returns the Slide inside.
Preconditions:
cursor is not null.
Postconditions:
The SlideListNode referenced by cursor has been removed from the list.
All other SlideListNodes in the list exist in the same order as before.
The cursor now references the previous SlideListNode (or the head, if the cursor previously referenced the head of the list).
Returns:
The reference to the Slide contained within the SlideListNode which was just removed from the list.
Throws: EndOfListException
Thrown if cursor is null.
3. PresentationManager Class
public static void main(String[] args) Brief:
The main method runs a menu driven application which first creates an empty SlideList and then prompts the user for a menu command selecting the operation. The required information is then requested from the user based on the selected operation. Following is the list of menu options and their required information:
A sample menu is provided below indicating the functionality your SlideList program should support:
F) Move cursor forward B) Move cursor backward D) Display cursor slide E) Edit cursor slide P) Print presentation summary A) Append new slide to tail I) Insert new slide before cursor R) Remove slide at cursor H) Reset cursor to head Q) Quit
4. EndOfListException Class
An Exception class which indicates that the user attempted to access a SlideListNode that does not exist (either before the head node or after the tail node). This exception can also be thrown when an operation is performed on an empty list (i.e. head, tail, and cursor are all equal to null).
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
