Assignment 7, due Mar 8
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!
ClassA x = (int i) -> i + 1; ClassB y = (ClassA j, int k) -> j.f( j.f( k ) ); int z = y.g( x, 1 );
a) What is the value of z? (0.5 points)
b) Give the appropriate definition for ClassA. (0.5 points)
c) Give the appropriate definition for ClassB. (0.5 points)
The revised version 2019-03-04, based on the solution to Homework 6, used sc.skip(theRest) followed by sc.match().group(0) to get and return what was skipped.
This change works despite the fact that sc.nextLine() and sc.skip(theRest) leave the scanner in different states.
a) What is the difference in the scanner state? (0.5 points)
b) Why does this difference in scanner state have no impact on the behavior of the rest of the program? (0.5 points)
A problem: What are some other classes in the Java library that could be used? (0.5 points)
Suggestion: Hunt through the Java documentation starting at PriorityQueue looking at the interfaces it implements and the other methods that implement those interfaces.