Assignment 10, due Nov 10
Part of
the homework for CS:2820, Fall 2017
|
Assignments are to be turned in on paper. On every assignment, write your name, course and section number at the top. Write your name as it appears in your university records! Use the section number for which you are registered! We will not do detective work to figure out who did what. Work must be legible. Homework is due on paper in discussion section, usually at the start except when the assignment indicates that time to work on the assignment will be provided in class. Exceptions will be made only by advance arrangement with your TA (excepting "acts of God" outside your control). Never push homework under someone's door!
a) Which of these classes must be marked as public? (0.2 points)
b) Which import directives are required? (The answer will be a subset of the list of import directives at the head of the MP4 version of Logic.java.) (0.2 points)
c) Class Gate includes an abstract method, inputChangeEvent. All subclasses of Gate have outputChangeEvent methods, but class Gate does not have an abstract outputChangeEvent declaration. Why? (0.2 points)
d) Which classes in file Gate.java can be declared to be final. (you do not need to do this in the code you submit code, but it is harmless to do so.) (0.2 points)
e) Which methods in the abstract classes in file Gate.java can be declared to be final. (you do not need to do this in the code you submit code, but it is harmless to do so.) (0.2 points)
if (newVal != value) { value = newVal; Simulator.schedule( time + delay, (float t) -> outputChangeEvent( t ) ); }
Scheduling an event that calls a method is not the same thing as calling the method directly, but we can still imagine this code as the result of applying this program transformation. In effect, we have passed a parameter to outputChangeEvent by assigning it to a field of the object and then calling the method.
a) Give the code for the "original" version of the above code, arrived at by reversing the transformation discussed here. (0.5 points)
b) As already mentioned, scheduling a method is not the same as calling it. As a result, the transformed code you gave in answer to part a) behaves differently from the code distributed in the assignment. Specifically, it behaves differently with respect to the "low pass filter" requirement of MP5. What is the difference? (0.5 points)
Notes: If you take the time to understand what's going on, the answer is short! It does not solve MP5, but understanding what is going on here will probably help you with MP5. Experiment and theory may be equally effective in understanding what's going on here.
a) Some of the elements (fields, inner classes, initializers, methods) of the class do not have Javadoc comments and ought to have them. Which? (0.3 points)
b) The Javadoc comment on the factory method contains an error. What is missing? (0.3 points)
c) The Javadoc comments for registerInput and inPinName ought to describe their relationship. Fix these comments so that they correctly explain their relationship. (0.4 points)