To get started, run update35 from a computer science lab computer. The program update35 will create a cs35/labs/04 directory in your CS home directory, and the program handin35 will subsequently submit files from that directory.
You may choose one partner for this lab. Both partners should be present and working on the code together. You will both be responsible for understanding all concepts, so dividing and conquering is not an option. The academic integrity policy applies to the entire pair; you cannot work or share code with anyone outside of your partner. Also, be sure to indicate who your partner is by including both names at the top of your files and by also selecting the 'p' option when using handin35 for the first time. Only one student in the pair should submit the lab.
You will earn reasonable partial credit for this lab if you complete and test your linked list implementation. So be sure to work in a modular fashion, testing and completing your linked list first before implementing the main program
This lab is inspired by a late-90s internet phenomenon known as ASCII-mation (head here to see Star Wars as you've never seen it before). Most of you are familiar with ASCII art, where basic characters and symbols are pieced together to represent an image. ASCII-mation takes this a step further by placing a series of ASCII images one after another until it looks like a movie. In this lab, you will create a movie player that will load an ASCII-mation movie and allow a user to perform some basic functionalities including general playing features (playing, pausing, stopping, fast forwarding, and rewinding) and basic editing features (deleting scenes or reversing playback).
As mentioned above, you will represent a movie as linked list of frames. You will then use basic linked list operations to implement the basic functionalities listed above for a movie player/editor. Most of the file format/playing features have been provided for you. One frame of the image will look similar to the following:
31
-=== `"',
""o o O O|) Going somewhere,
_\ -/_ _\o/ _ Solo?
/| || |\ /|\ / |\
//| || |\\ //| | |\\
|| | || | \\ // | | | ||
|| |/ \| \\ -==# | | | ||
|! |====| ') '\ |====| /#
=] |/|| | | || | "
I ( )( ) | || |
|-||-| | || |
| || | | || |
________________[_][__\________________/__)(_)_____________________
We will represent the text for the frame as one large string.
The value in the upper left-hand corner (e.g., 31) is to compress the file
size. It represents how many frames in a row looked the same as this.
The movie has been filmed at 15 frames a second, so a value of 31 means that
this image appears on the screen for 31 frames, or just over 2 seconds.
Here, I list the requirements for each major component of the lab. See the IMPLEMENTATION STRATEGY section below for hints on how to begin attacking the problem.
You have been given the following files (blue indicates you will need to modify/implement in this file):
I have provided a MovieList interface, very similar to the StringList interface given in lecture. A MovieList defines the normal list functionality, but adds remove (removes the data at position i) and a playFrom method specific to this task. Recall that the interface is not the implementation, so we could theoretically use either arrays or linked lists to implement a MovieList.
You must define and implement a MovieLinkedList class that implements the MovieList interface, without altering the MovieList interface.
Once you have thoroughly tested your MovieLinkedList implementation, you should implement the main program. The program has been started for you. To keep the program clean, we have divided the main program into three files. player.cpp only contains the main loop. Modify this to get it working, but any large implementation details should be done in the helper files. Those details should use good top down design (e.g., one function per feature). Any functions should be declared and defined in movie.h/.cpp respectively. We have provided getChoice() for you as an example. To complete the main program:
You are watching scenes/starwars.ani You are currently at 0hr 0min 0sec
You should always program incrementally such that you can test your work as you go. Here is one suggested strategy:
/* get - returns the value for the ith item in the list
@param i, an int for the index of the frame to return
@return a string containing a scene from the film
*/
string MovieLinkedList::getFrame(int i){
//TODO: implement this
return "EXAMPLE FRAME";
}
You should not under any circumstances begin the movie player implementation until you have thoroughly verified the correctness of your MovieLinkedList class. Any bugs in your MovieLinkedList class will hinder progress on the main program. Begin working on player.cpp by implementing and testing one feature of the program at a time. Be sure that your solution follows good design/modularity guidelines.
Your linked list should handle invalid usage by throwing a runtime_error. There is an example in the playFrom method in movieLinkedList.cpp as well is in the ArrayStringList implementation from class. For example, if you may want to handle an attempt to get an invalid item:
throw std::runtime_error("Attempt to get out of bounds");
Here is an example of handling a runtime_error (not required in this lab):
try{
//do something dangerous
} catch (runtime_error& exc){
cerr << "Warning: " << exc.what() << endl;
cerr << "Ignoring illegal behavior." << endl;
}
Don't forget to include the stdexcept
library when handling or throwing exceptions.
Once you are satisfied with your program, hand it in by typing handin35 at the unix prompt.
You may run handin35 as many times as you like, and only the most recent submission will be recorded. This is useful if you realize after handing in some programs that you'd like to make a few more changes to them. Only one partner should hand in the code for the lab.