CSSE 120 -- Intro. to Software Development

Homework 8

Reminder: for each class session and associated homework:
  • You do the Reading Quiz on Angel.
  • You do all other work in Eclipse in the project that you checked out for that session or will check out per the homework instruction.
  • Unless otherwise specified, follow the template given in homework 2 for solving each programming assignment.
  • You turn in your Eclipse work by committing that project:
    • Right-click on the project name in the Package Explorer view.
    • Select Team ~ Commit
    • In the message box that appears, put a message to yourself if you wish (eventually, these messages will be for your teammates) and press OK.

  1. Complete the assigned reading for the next session, Zelle chapter 6.
  2. (28, 10 pts) Complete two ANGEL quizzes over this reading. You'll find them on the course ANGEL page, under Lessons → Homework → Homework 8 → Defining Functions,  More Functions
  3. (25 points) File Input
    1. Checkout the 08-FuncPlot project from your SVN repository.
    2. Write a program in module funcPlot.py that implements the following design:
      • Prompt the user for a file name
      • Open a file with the given name
      • Display a graphics window with width 720 and height 400.
      • Read each line from the file. For each line, plot a point on the graphics window. You should assume the lines have the format specified in funcDump (treat the first number as the x coordinate and the second number as the y).
      • Close the file
    3. Test your program using your cos.txt output from funcDump. (Note: you must place cos.txt in the same folder as funcPlot.py to read it.) You may also test using the sample outputs for different functions below. (The functions are "upside down" because of the graphics coordinate system. You could fix that by using zellegraphics' win.setCoords() method if you so desired, but we won't require it.)
    4. Commit your solutions to your SVN repository.
  4. (40 points) Photo slideshow. (Note: we suggest that you do the funcPlot problem above BEFORE the SlideShow problem. Doing so will help you through some of the file reading issues that may otherwise hang you up in SlideShow.) These days, many people use their computer as a "digital shoebox" of photographs. You will write a program to present a slideshow of a number of photos, in an order that you specify in a text file.

    1. Checkout the 08-Slideshow project from your SVN repository.
    2. Write a program in the module slideshow.py that implements the following design:
      • Prompt the user for the name of a runlist, a file that contains a list of image file names
      • Open the runlist.
      • Read the next image file name from the runlist file, one at a time, and display the corresponding image in a graphics window. When the user clicks in the window, the slideshow advances to the next image.

        Notes and Hints:

        1. An Image is an object just like a Rectangle or a Circle. You can find help for how to use it in the ZelleGraphics help pdf file you got on day 1 when you installed zellegraphics.py.
        2. Slideshow should display no more than one image at any given time. An image should be displayed as long as there are image file names yet to be read from the input file. When the user clicks on the last image, the program will end.
        3. If you draw a small image on top of a large one, you can see both, which looks messy. However, in Zelle Graphics, you can tell the window to undraw any object; for example, to undraw an image called photo, use photo.undraw()
        4. You will need to strip off the newline character from each line you read in. Use the string class' strip() function to do this (import string and see help string.strip() for details). Unfortunately, slicing with a negative index (myList[:-1]) doesn't work on Windows like you might expect.
      • Close the file.
    3. Test your program.
      • We have placed 4 photos in the 08-Slideshow project. We have also given you 3 files containing lists of those photos in various combinations: runlist0.txt has a single photo, runlist1.txt lists 3 other photos, and runlist2.txt has all 4 photos in a different order and with one repeated. These files are placed in the folder that contains slideshow.py. Run your program with each of these 3 runlists.
      • Optional: Have some fun creating a slideshow of your own photographs. Notes: The textbook says "most platforms will support JPG, GIF, and BMP files."; unfortunately, it appears that JPG files don't work in Windows. So gather images of the other format or convert them to GIF using Paint or some other program and place them in the same folder that slideshow.py is in.
    4. Commit your solutions to your SVN repository.