Lesson 07 In-Class Exercises

Before starting any specific exercise, you may wish to download, extract, and open up the provided starter project for this lesson so that you'll have it ready when you need/want it.

Part 1: Passing an object to & from a method

Download, extract, and open up the provided starter project for Visual Studio.  In the Program.cs file you will find the Compare_Two_Movies.RunExercise method, which you will trace through using this file: trace file for Compare_Two_Movies.RunExercise().

Keep in mind that unlike BIT 115 (wherein you were expected to transcribe each and every line as you hand-executed the entire program) in these exercises you are expected to mentally simulate the execution of the program, updating the trace as you go. 

In order to have a well-defined, consistent procedure for y'all to follow, you should do the following: start mentally simulating the program, using the top-most cell in the trace file as your 'scratch space' to keep track of what the program is doing - we're going to call this the 'current cell'.  When you see a comment that that looks like: // SWITCH TO NEW CELL IN THE TRACE FILE you should copy all the values from the current into the cell below it, and then you should switch to using that new cell as your current cell  

Be prepared to walk the class through your trace, verbally explaining the execution of the program while using the trace to illustrate the value of variables at various points in the program's run.

Tip:  You can make new cells for yourself by moving your mouse pointer just to the left of the rows that you want to copy (the mouse icon will become an arrow, rather than the normal Word cursor bar), selecting the rows, and then copying (Control+C) the rows, moving the cursor down below the last table and pasting (Control+V). 

Pro Tip: Many people find it very, very effective to print out the trace file and fill it out by hand. 

Part 2: A simple array WITHIN a class

Trace through the TestGradeTracker.RunExercise method using this file: trace file for TestGradeTracker.RunExercise.

Be prepared to walk the class through your trace, verbally explaining the execution of the program while using the trace to illustrate the value of variables at various points in the program's run. 

Part 3: An array of objects WITHIN a class

 Trace through the TestMovieLibrary.RunExercise method using this file: trace file for TestMovieLibrary.RunExercise.

Be prepared to walk the class through your trace, verbally explaining the execution of the program while using the trace to illustrate the value of variables at various points in the program's run.

Part 4: PCE Review: Defining a Polymorphic method

Define the Movie_3D class, which extends the basic Movie class.  All it has to do is override the Print method and call the base class version of Print, then print out the message THIS MOVIE IS IN 3D!!!!1!.

Once you're done, the TestPolymorphism.RunExercise() method should produce this output:

Movie object
        Title:  The Avengers (2012)
        Director:       Joss Whedon
        THIS MOVIE IS IN 3D!!!!1!
Movie object
        Title:  Buffy The Vampire Slayer (1992)
        Director:       NO NAME PROVIDED

Part 5: PCE Review: Polymorphic method in an array

Trace through the TestPolymorphicArray.RunExercise method using this file: trace file for TestPolymorphicArray.RunExercise.

Be prepared to walk the class through your trace, verbally explaining the execution of the program while using the trace to illustrate the value of variables at various points in the program's run. 

One Last Note

There's a file containing an example solution for some of the exercises in the .ZIP of the starter project.  Feel free to look at it after you've done the work for a given section, but remember that you won't learn unless you actually do this work yourself!

One Minute Paper

"A “one-minute paper” may be defined as a very short, in-class writing activity (taking one-minute or less to complete) in response to an instructor-posed question, which prompts students to reflect on the day’s lesson and provides the instructor with useful feedback." (from http://www.oncourseworkshop.com/Awareness012.htm).

For this One Minute Paper, I would like you to think back on both the preview videos / viewing quiz and today's in-class exercises, and quickly write up answers to the questions listed therein - it should take a couple minutes or so.

Head on over to the Google Docs form, and fill out the One Minute Paper for this lecture.