CSCI 159 Lab 2 exercises

Lab2 will consist of two parts:

Hopefully most people complete all of the basic exercise and get a good start on the main exercise within their scheduled lab section on Sept. 16/18th.

Here is the collection of new C++ syntax elements we'll be using for lab2.


Refresher: logging in and setting up

  1. logging in

  2. opening the browser and today's lab page

  3. opening a terminal window

  4. using make159 to get lab2

  5. getting into lab2 and the edit/compile/test/submit cycle


New: getting feedback/marks from the previous lab(s)

  1. getting the feedback directory the first time

  2. updating the feedback directory (for later labs)

  3. seeing the feedback files


Part 1: the basics of this lab's new C++ features (basic.cpp)

For the first part of today's lab exercise we're adding code to a program to experiment with some of of the more unusual behaviour and limitations of simple data types, while also learning to 'code to standards' as we go. Of course we'll get more practice with the edit/compile/test/submit cycle as we go.

We'll also try to create and call a function of our own: passing data to it, having it perform computation and return a result which our main routine can then use.

Go through the various steps, adding each to your basic.cpp main routine as you go.


Part 2: design and implementation exercise (lab2.cpp)

Now that we've practiced using each of our new C++ features, our objective is to design, write, test, and debug a more interesting program in our lab2.cpp file.

The behaviour we want from our program is as follows:

Take some time to come up with a design - figuring out what functions you want/need to write/call, what you want each of them to do, and how you want to structure your logic in the main routine.

Taking the time to come up with a good design will, in the long run, result in much cleaner and better organized code: code that is easier to write, understand, debug, and maintain.

Good design takes practice though. Don't worry if you have to significantly revise your original design a couple of times as you work through the coding practice: it's normal to recognize the need for some changes as you start getting deeper into the actual code.

If you're having trouble getting started, go to the lecture resources and check out the sections on design and modularity listed under Sept. 23-27. There are also many good resources online to help new programmers learning to design.

In next week's lab time (Sept 16/18) we'll spend about 45 minutes on the first quiz, but the instructor will be available to talk about your design ideas/issues once you're finished with your quiz.