Assignment 12, due Apr 26
Part of
the homework for CS:2820, Spring 2019
|
Assignments are to be turned in on paper. On every assignment, write your name, course and section number at the top of each page. 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!
public static void main( String[] args ) { ClassA p = (int i) -> 2 * i; // a ClassB q = (ClassA j) -> ( (int k) -> j.x( j.x( k ) ) ); // b ClassA r = q.y( p ); // c int s = r.x( 1 ); // d }
You saw this in Exam II, and you are welcome to use the code from the posted solution to the exam to test your solution to this probmem.
A problem: Rewrite the line that defines and initializes q so that it uses explicitly declared and named outer classes and no λ-expressions.
This is just like HW11, except that you now have to get rid of all nested classes, which mans things get more interesting. Since working code has been posted for both the homework and exams, you are free to test your solution. Work incrementally! (1.0 points)
We divided the classes into layers, putting classes that depended on none of the other classes in our project at the top, and arranging things so that all dependency arrows between layers pointed upward. Within a layer, it was common to have knots, where some of the classes in a layer may depended on each other with circular dependency loops.
A problem: Draw the class dependency diagram for the road network simulator. Be warned that this will not be the same as the diagram for the logic simulator because of an important difference in their internal structure.
Please make a rough draft to throw away first, because neatness really does count. Also, please do not include extra arrows: If class A depends on class B and class B depends on class C, there is no need to put arrows from A to C even if there is a direct reference in A to C. These extra arrows just make the whole diagram harder to read. (1.0 points)
A /|\ B C=D \|/ E
I can't type arrow heads, so here's a translation into English: B depends on A, C depends on A and D, D depends on A and C, and finally, E depends on B, C and D.
Please assume that each class is in a separate .java file.
a) If you type javac A.java which classes get compiled? (0.2 points)
b) If you type javac B.java which classes get compiled? (0.2 points)
c) If you type javac C.java which classes get compiled? (0.2 points)
d) If you type javac D.java which classes get compiled? (0.2 points)
d) If you type javac E.java which classes get compiled? (0.2 points)