package presentation;
import java.util.Collection;
import java.util.List;
/**
* The Presentation document is derived primarily from section 2.2
* of the requirements, and is the central document in E-Class.
* A Presentation contains both slides and topics, which are linked
* to each other.
*
* A Presentation also maintains the index of the currently viewed
* slide, and provides operations to change slides. These are derived
* from sections 2.3.2, 2.3.3 and 2.4.1 of the requirements.
*/
public abstract class Presentation {
/** Slides in the presentation. */
List slides;
/** All topics in the presentation (interrelated in a tree structure). */
List topics;
/** Which slide is currently viewed, an index into 'slides'. */
int currentSlide;
/**
* Advances the presentation to the next slide.
*/
/*@
requires
//
//The current slide is not the last slide in the presentation
//
(currentSlide < slides.size());
ensures
//
//If the presentation is not at the last slide, it advances to the next slide
//
(currentSlide == \old(currentSlide) + 1);
*/
abstract void nextSlide();
/**
* Moves the presentation to the previous slide.
*/
/*@
requires
//
//The current slide is not the first slide in the presentation
//
(currentSlide != 0);
ensures
//
//If the presentation is not at the first slide, it moves to the previous slide
//
(currentSlide == \old(currentSlide) - 1);
*/
abstract void prevSlide();
/**
* Moves the presentation to the first slide.
*/
/*@
requires
//
//The current slide is not the first slide in the presentation
//
(currentSlide > 0);
ensures
//
//If the presentation is not at the first slide, it moves to the first slide
//
(currentSlide == 0);
*/
abstract void firstSlide();
/**
* Advances the presentation to the last slide.
*/
/*@
requires
//
//The current slide is not the last slide in the presentation
//
(currentSlide < slides.size() - 1);
ensures
//
//If the presentation is not at the last slide, it advances to the last slide
//
(currentSlide == slides.size() - 1);
*/
abstract void lastSlide();
/**
* Advances the presentation to a given indexed slide.
*/
/*@
requires
//
//The slide index given is within the bounds of the presentation
//
(0 <= slide && slide < slides.size());
ensures
//
//If the presentation is not at the indexed slide, it advances to the indexed slide
//
(currentSlide == slide);
*/
abstract void goToSlide(int slide);
/**
* Advances the presentation to the slide associated with a given topic.
*/
/*@
requires
//
//The topic is a valid topic and has associated slides
//
(topics.contains(topic) == true);
ensures
//
//If the presentation is not at the current topic, it advances to the current topic
//
(slides.get(currentSlide) == topic.slide);
*/
abstract void goToTopic(Topic topic);
/**
* Breaks a slide into two, starting with a specified topic.
*/
/*@
requires
// The requested index refers to an existing slide
(0 <= slide) && (slide < slides.size())
&&
// The requested index refers to a valid topic on that slide
(0 <= topic) && (topic < slides.get(slide).topics.size());
ensures
// The indicated topic and later topics on the slide are on a new slide
(\forall int i; i >= topic && i < \old(slides.get(slide).topics.size());
slides.get(slide + 1).topics.contains(\old(slides.get(slide).topics.get(i))))
&&
// and all other topics are still on the same slides.
(\forall Topic t; topics.contains(t) && ! \old(slides.get(slide).topics.contains(t));
t.slide == \old(t.slide));
*/
abstract void breakSlide(int slide, int topic);
/**
* Imports a presentation from an HTML file, as described in
*
* section 2.2.2 of the requirements.
*/
static Presentation importHTML(String filename) {return null;}
/**
* Saves the presentation content to a file.
*/
abstract void saveToFile(String filename);
}