Project 2: The Screen Class

CSE 143
Summer 1998

For this assignment, you will implement a Screen class, an abstraction of the contents of a screen. You will also write a client of that class.

This assignment will emphasize the mechanics of implementing a class, and using that class to perform some larger task. It will also emphasize code reuse; points will be deducted for unnecessary replication of code to achieve similar functionality.

Detailed Specification

  • Program organization: Your project will consist of 3 files. One of these we have supplied:

    You will also provide two files, screen.cpp which implements the class specified in screen.h, and main.cpp which implements the client of the Screen class.

    A code outline for the client is privided as main.cpp. The client you will write should read commands from standard input and execute them. The commands to be accepted are:

    fill 'c'
    Fill the entire screen with the character 'c'. The implementation of this command is given.
    hline <column> <row> <length> 'c'
    Draw a line from (<column>,<row>) to (<column>+<length>-1,<row>), made entirely out of the character 'c'. The implementation of this command is given.
    vline <column> <row> <length> 'c'
    Draw a line from (<column>,<row>) to (<column><,row>+<length>-1), made entirely out of the character 'c'. Your implementation should read in 'c' using the readChar function provided.
    rectangle <column> <row> <width> <height> 'c'
    Draw a rectangle from (<column>,<row>) to (<column>+<length>-1,<row>+<length>-1), filled with the character 'c'.
    text <column> <row> "some text to write"
    Write the text in the quotes starting at position (<column>,<row>). Your implementation should read in the text in quotes using the readText function provided.
    ctext <row> "some text to write"
    Place the text in quotes centered on row <row>. Your implementation should read in the text in quotes using the readText function provided.
    load <filename>
    Replace the contents of the screen with the contents of <filename>. <filename> is given with no quotes, such as
    load BLAH.SCREEN
    save <filename>
    Save the contents of the screen to a file given by <filename>.
    print
    Print the screen to the console
    quit
    Quit the program
    Check out the sample input file input.txt if you are unclear on the format of the commands.

    Many of these commands can fail because of bad parameters. You should know when things fail because the method calls on the screen instance should return 'false'. If this happens, you should print the string "Error." to the console, abort the operation, and continue processing commands.

    You can assume that input to your interpreter is well formed, i.e., each command line has a valid command and an appropriate number of parameters.

    Executable

    To verify that your screen class implementation is working correctly, we encourage you to compare it against our sample solutions. The following link allows you to download a sample Windows executable to help you with your implementation of the command interpreter.
    The following links will allow you to download sample Windows and x86 Linux executables. These should produce results identical to those you get by linking in your implementation of the Screen class with mandel.cpp.

    Turn-In

    Homework 2 is due on Monday, July 13th, 1998, at 5:00pm. You will turn in your homework using a form on the course web, and you will be unable to submit your homework after 5:00pm. Please plan your time so that you will not be trying to submit your assignment at 4:59.

    When you're finished writing your solution, you can use the electronic turn-in form to submit it. Follow the instructions on that form (especially with regards to file naming conventions), print the receipt, and submit the receipt at the start of section, Tuesday, July 14th, 1998. For full credit, you must turn in electronically, print the receipt, and hand in that receipt in your section. You may also be able to drop your receipt in the drop box located on the first floor of Sieg hall, across from room 127. More details on this will follow.

    If You Get Stuck

    If you're having problems, there are a number of resources available for you.

    If you need help with the lab environment or the online resources, go talk to a consultant in the IPL.

    If you can't make progress in the actual assignment, please talk to the instructor or a TA. They are available during posted office hours, and sometimes by appointment. They will also occasionally help you out over email. You are invited to seek help from any available TA, not just your own.

    You can discuss the assignment in general terms with other students. You can ask general questions on the student discussion list for this course, cse143@cs. But any code you write must be your own. For more details about what is and is not allowed, see the Software hygiene page.


    cse143-webmaster@cs.washington.edu