CS 70

Homework 3: Exploring the Display Class

In this Step, we will explore the Display class, which is responsible for managing the terminal display using the ncurses library. The Display class encapsulates all ncurses functionality to provide a simple interface for displaying characters on the terminal. It handles initialization, cleanup, and drawing operations.

In this case, you don't need to (and in fact must not) modify any code in the Display class. Instead, you will be using its public interface to implement the display functionality in the Asciimation class in the next Step, so it's a good idea to understand the functionality it provides.

Your Task

Explore the Display Class's Interface

Read through the display.hpp to determine what functionality the Display class provides. Pay special attention to the public member functions, as these are the functions you will be using in the next step of the assignment where you use this functionality to implement in the Asciimation class.

Run the display-test Executable

Once you have explored the Display class's interface, you should run the display-test executable to see a demo of some of the things the Display class can do. You can run it by executing the following command in your terminal:

./display-test

The command will complain if your terminal is not large enough. In some terminals, it will automatically resize the terminal window for you, but Visual Studio Code's terminal does not support this feature; when it can't resize the terminal to be big enough, it will complain but still work, just some of the content that should be seen won't be visible.

  • Rabbit speaking

    One option to avoid this problem is to run the program in a separate terminal window outside of VS Code, where you can manually resize the window to be large enough. The Mac has a program called Terminal, and Windows has a program called Command Prompt or PowerShell. If you're using Linux, you probably already know how to open a terminal window. Open a terminal and ssh into the course server, then navigate to your homework directory and run ./display-test there.

Explore the display-test.cpp Code

Having seen the display-test program in action, you should now read through the display-test.cpp code to see how it uses the Display class's public interface to create the what you saw on the screen. This will help you understand how to use the Display class in your own code.

Helpful Hints

  • LHS Cow speaking

    Here are some tips for exploring the Display class!

You Don't Need to Look at display.cpp

While you are welcome to look at the implementation of the Display class in display.cpp, you do not need to do so for this assignment. The class is already fully implemented, and you should focus on understanding its public interface as defined in display.hpp.

  • RHS Cow speaking

    The code uses some C++ features we haven't covered yet in class, as well as some C++ and Unix features that are outside the scope of this course. For example, it contains special code to handle program crashes so that if your code goes wrong, it won't leave your terminal in a messed-up state. You don't need to understand how this works for this assignment, but if you're curious, you can look up signal handling in C and C++.

To Complete This Part of the Assignment

You'll know you're done with this part of the assignment when you've done all of the following:

(When logged in, completion status appears here.)