EECS 211
Getting Started Exercises

Below are exercises suitable for submission to the Code Critic after reading Chapters 1 through 3 of the textbook. Don't forget the rules of the queue.

The exercises are:

Do these exercises in order. Because these exercises build on each other, do not submit the next exercise until you've gotten a clean approved version of the previous exercise.

Setting Up

Before you can do any assignment, you need to set up your development environment. For this course, you will need:

The Unix environment is already available on Linux and MacOS X machines. For Windows, download and install Cygwin.

The CppUnit instructions say how to get CppUnit for different operating systems.

Integrated Development Environments

Programming multi-file multi-library applications is a lot easier with an integrated development environment (IDE). These provide editors that know how to edit and run program code quickly and easily. Many provide support for using the same Makefile's that make uses.

For this course, if you want to use an IDE, I recommend but do not require Code::Blocks for Windows users and XCode for MacOS X users as development environments.

IDE's such as Microsoft Visual Express should not be used. They do not support Makefiles, so I can't easily and automatically compile and test your code, and they often do not support modern standard C++ well.

After you get yourself set up, the first exercise is to improve the Makefile that I provided. The second exercise is to get a little practice using CppUnit to do test-driven development for some simple code.

Exercise: make handin

Recommended Reading: In your Unix shell, or in Google, do man zip, man unzip, and man make to find out the options for these Unix tools. You could also Google gnu make manual if you want to know all the gory details about Makefiles, but that's overkill for this exercise.

Makefiles are popular because you can do many project-related actions with them, not just compiling code. A common action is creating packages of project files for distribution.

Your job is to extend your 211 Makefile template so that make handin creates a Zip archive of a project to hand in as your wrapup.

Use this modified Makefile for all your future assignments. In software development circles, this is called "eating your own dog food."

Specifically, make handin should

Also, change make clean to remove the project Zip file, if any.

Test: Make sure that:

Submit to Code Critic:

Wrap Up

When the above has been approved via the Code Critic, run make handin.

Email the Zip archive produced by your Makefile with the Subject EECS 211: Make handin.

Exercise: GradeBook Course Name

Chapter 3 of the textbook starts the construction of a GradeBook class. There's not much in it yet, but that doesn't mean it's not ready for unit testing. Of course, the tests should've been written first.

Make a project with the code from Figures 3.15, 3.16 and 3.17. Don't type the code in! Get it from the book site (registration required). You want the files in CppHTP6e_examples/ch03/Fig03_15_17.

Put those files in a 211 project directory called gradebook.

Copy your 211 Makefile from the previous exercise, and edit it to build gradebook.exe from your gradebook files.

Create a Code::Blocks or XCode project if desired.

Compile and run your project. Make sure you get the output shown in Figure 3.17 on page 116.

While this verifies that the code compiles and run, it's a terrible way to see if the code is doing the right thing in all cases. So now create a GradeBookTests.cpp file, following the 211 CppUnit template. Create at least one test function to make sure that both the constructor and GradeBook::setCourseName():

The example names used the Deitel code are not enough. To thoroughly test code, you need to check things at the edges, where many bugs lie.

C++ strings are covered in detail in Chapter 18, but all you need to know is:

Test! Change your Makefile to use GradeBookTests.cpp. Compile and run your project. Do all your tests pass? If not, which is wrong? The tests or the code? If it's the tests, fix them. If it's the code from the book, leave it.

Submit to Code Critic:

Do not submit Deitel code.

Wrap Up

When the above has been approved via the Code Critic, run make handin.

Email the Zip archive produced by your Makefile with the Subject EECS 211: Gradebook Course Name.

Exercise: Account Class

In this exercise, you do true TDD, starting with no code, just tests. Be sure to read:

Exercise 3.12 describes a simple bank account class. Develop Account using TDD. The CppUnit page does the very first step in this example. Follow the pattern it shows of writing tests first, before coding a solution. Be sure to:

Ignore the final comment in the book about creating two Account objects. Do what you think you need to do to adequately test the account code.

Submit to Code Critic:

Don't submit your Makefile.

Wrap Up

When the above has been approved via the Code Critic, run make handin.

Email the Zip archive produced by your Makefile with the Subject EECS 211: Account Class Ch 3.

Comments? comment icon Contact the Prof!

Valid HTML 4.01 Transitional