Assignment 12, due Apr 28

Part of the homework for CS:2820, Spring 2017
by Douglas W. Jones
THE UNIVERSITY OF IOWA Department of Computer Science

On every assignment, write your name and section number. Write your name as it appears on your university ID card! Use the section number as it appears in your current registration! We will not do detective work to figure out who did what. Homework is due on paper at the start of your discussion section. Exceptions will be made only by advance arrangement with your TA (excepting "acts of God"). Never push homework under someone's door!

  1. Background: The code distributed for MP6 is not the end of the story. Consider the code given in class TernaryLogic. This class contains several subclasses of Simulation.Event.

    It might make sense to crack initPrint and PrintEvent into a separate source file. It is easy enough to rip them out of TernaryLogic, but they need access to a variable or variables that are private to TernaryLogic.

    Suppose we name the new class PrintEvent, with the static method initPrint local to PrintEvent. This architectural change has consequences.

    a) What variable or variables pose difficulties? (0.3 point)

    b) In light of part a, what are the parameters to initPrint? (0.3 point)

    c) In light of parts a and b, what private static variables should be in class PrintEvent? (These may replace or supplement existing variables.) (0.4 point)

  2. Background: Look at class Wire in the code distributed for MP6.

    a) One of the simulation classes can be private. Which one, and why must the other one remain public? (0.5 point)

  3. Background: Look at the code for class Gate in the solution distributed for MP5.

    a) Which methods in class Gate must be replaced by inner classes (with their own methods) in a solution to MP6? (0.5 point)

    b) One of these new classes can be a private or protected inner class. Which one and if it must be protected, explain why with reference to the code distributed for MP6. (0.5 point)

    c) One of these new classes cannot be private or protected because of the way it is referenced from elsewhere. Where is the reference to it from elsewhere in the code distributed for MP6. (0.5 point)