hw3spec - <?xml version="1.0"...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
<?xml version="1.0" encoding="ISO-8859-1" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>CS32 Homework 3, Winter 2010</title> </head> <body> <div align="right"> Winter 2010 CS 32 </div> <div align="center"> <h2>Homework 3</h2> <p> <strong>Time due: 9:00 PM Sunday, February 7</strong> </p> </div> <ol> <li> <p> You are developing software for Crapple's next device, the iBad. Among its capabilities is the ability to access video, audio, and text files. Every file has a name. Each kind of file has a distinctive action that's taken when it is opened. A client can ask to redisplay a file; for most kinds of files, this does nothing, but some kinds of files may do something interesting. </p><p> Declare and implement the classes named in the sample program below in such a way that the program compiles, executes, and produces exactly the output shown. (A real implementation would actually play videos and show pictures, but for now we'll stick to simple text output.) Do not change the implementations of <code>openAndRedisplay</code> or <code>main</code>. </p> <pre> #include <iostream> #include <string> using namespace std; <em>Your declarations and implementations would go here</em> void openAndRedisplay(const File* f) { cout << f->name() << ": "; f->open(); cout << endl << "Redisplay: "; f->redisplay(); cout << endl; } int main() { File* files[4]; files[0] = new TextMsg("fromFred.txt"); // Videos have a name and running time files[1] = new Video("kitty.mpg", 57); files[2] = new Picture("poster.jpg"); files[3] = new Picture("still.jpg"); for (int k = 0; k &lt; 4; k++)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
openAndRedisplay(files[k]); // Clean up the files before exiting cout << "Cleaning up" << endl; for (int n = 0; n < 4; n++) delete files[n]; } </pre> <p> Output produced: </p> <pre> fromFred.txt: open text message Redisplay: kitty.mpg: play 57 second video Redisplay: replay video poster.jpg: display picture Redisplay: still.jpg: display picture Redisplay: Cleaning up Destroying fromFred.txt, a text message Destroying kitty.mpg, a video Destroying the picture poster.jpg Destroying the picture still.jpg </pre> <p> Decide which function(s) should be pure virtual, which should be non-pure virtual, and which could be non-virtual. Experiment to see what output is produced if you mistakenly make a function non-virtual when it should be virtual instead. </p><p> To force you to explore the issues we want you to, we'll put some constraints on your solution: </p> <ul> <li> The File class must not have a default constructor. The only constructor you may declare for File must have one useful parameter. </li><li>
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/08/2010 for the course COM SCI 32 taught by Professor Smallberg during the Spring '07 term at UCLA.

Page1 / 7

hw3spec - &lt;?xml version=&quot;1.0&quot;...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online