Lesson 04 In-Class Exercises

Part 1: Nested Classes

Download, extract, and open up the provided starter project for Visual Studio.  In the Program.cs file you will find a class named FrequencyCounter, which uses a separate class (named NumberCounterPair) in order to actually store the various numbers and their frequencies.

Your task is to take the NumberCounterPair class, and to make it into a nested class within the FrequencyCounter class.  This should include moving the class definition, setting the overall access on the class to be private (so that nothing outside of the FrequencyCounter class can access it, setting the individual data fields to be public, and then remove the (now unneeded) getter/setter methods.

Part 2: Pseudocode: LinkedList.AddAtFront

For this exercise you need to write up pseudocode for the AddAtFront method on the MyIntList class.  This class is defined in the starter project for the POST Class Exercises, and is listed below for convenience.  If you need more detail on any given method you should find the document/exercise in the PCEs which describes what the method in question should do.  You need to write up pseudocode for each of the methods of the MyIntList class that you'll be implementing during this week's PCEs using this document

Be ready to present your pseudocode to the class, and to walk the class through the logic of your solution.

public class MyIntList
{
    // instance variables, if any
    protected IntListNode first; // protected so that the subclasses can get to it
 
    public void AddToFront(int numToAdd) // write this one up now
    {
    }
 
    public void RemoveFromFront()	// write this one up in the next exercises
    {
    }

    public void PrintAll()		// write this one up in the next exercises 
    {
        Console.WriteLine("You need to implement this!");
    }

    public void PrintNode(uint i)	// write this one up in the next exercises
    {
        Console.WriteLine("You need to implement this!");
    }
}

Part 3: Pseudocode: LinkedList.RemoveFromFront

This exercise is basically the same as the prior exercise, except that this is for the RemoveFromFront method.

The instructor is breaking up the overall goal of "write pseudocode for all the methods" into separate parts so that it will be easier to clearly identify which method everyone should be working on.

Part 4: Pseudocode: LinkedList.PrintAll

This exercise is basically the same as the prior exercise, except that this is for the PrintAll method.

Part 5: Pseudocode: LinkedList.PrintNode

This exercise is basically the same as the prior exercise, except that this is for the PrintNode(uint i) method.

Extra-Challenging Questions/Exercises:

  1. Stack of Simple Types vs. Reference Types  
  2. Test-driven development: Implementing a stack of circles 
  3. Preview: Print At Index

Future Ideas

 

 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 two questions:

  1. What was the thing that you were most confused about at the start of this lecture? (Also let me know if you're still confused about this)
  2. Which of the in-class exercises and activities were most helpful to you, and why?

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