 |
The Horstmann textbook used in CS 201 provides sample classes that can
be used in the programs you write. The first step is to download these
files. Note that these files have been modified from the ones distributed
with the text in order to enable them to compile properly with the compiler
we are using.
Download needed files
The following instructions will tell you how to download the files you
need. You only need to do this once.
- Right-click on the following link: http://www.cs.bgsu.edu/rlancast/download/cs201.zip.
- To download, select "Save Target As..." and choose your USB
flash drive. On your home computer system, you can choose any location
for this file.
- Find the file you just downloaded, right-click on it, and select
"Extract All...".
- This will start a program to extract the files. Click "Next>" or
"Finish" in each window you see.
- After you have completed this, you can delete the file named
cs201.zip .
Running a program using the Employee, Time, or a graphics class
- Start Microsoft Visual Studio 2005.
- Choose File | New | Project and you will see this
screen:

- Click on Visual C++ in the left pane and click on "CLR Empty Project"
in the right pane. Fill in the project name (Name:) and click the Browse
button to select a directory for your project. Select a location on
your personal hard disk or on a USB flash drive in a computer lab.
Be sure that the box labeled "Create directory for solution" is
unchecked. A new folder will be created in the specified location with
the project's name. Then click OK. For this example, we assume drive
E is the flash drive we are using.
- You will now have a solution folder whose name is the same as your
project name. Copy the CS 201 files you downloaded above into the
solution folder. For the Time class, copy ccc_time.h and ccc_time.cpp.
For the Employee class, copy ccc_empl.h and ccc_empl.cpp. For the
graphics classes, copy all files that don't refer to time or
empl.
- In Visual Studio's Solution Explorer window (typically upper
right), right-click on Headers, select Add Existing Item, and chose the
header files that you just copied to the solution folder. (Use
Ctrl-click to select multiple files.)
- Now right-click on Source Files, select Add Existing Item, and
choose the cpp files that you just copied to the solution folder.
- Right-click on Source Files, select Add New Item. You will see this
dialog:

- Click Code in the left pane and C++ File in the right pane. Enter
"main" in the Name field at the bottom and click Add. This will open a
window for you to type your main program.
- Compile and execute your program by pressing F5 or clicking
Debug | Start.
- If there are error messages in the bottom window, double-click on
each message to go to the location of the error in your file. Fix the
errors and attempt to compile and execute your program again.
|