Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Consider the code given in class TernaryLogic. This class contains several subcl

ID: 3828273 • Letter: C

Question

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?

b.) In light of part a, what are the parameters to initPrint?

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

Explanation / Answer

a. The variable 'gates' creates problem as it is a static member of the outer class

b. The LinkedList gates will become a parameter for initPrint

c. No other private static variable is needed in the class PrintEvent