In the previous lecture, we discussed a Piazza-like system. Suppose the class names for student posts and responses are Post
and Response
. (Only one class for responses, whether by student or instructor.) What is the relationship between these classes?
Which of the following diagrams correctly describes the relationship between the given classes?
Consider this code snippet:
Scanner in = new Scanner(new FileReader("input.txt")); while (in.hasNextLine()) { String line = in.nextLine(); System.out.println(line); }
What is wrong about this sequence diagram?
read
on the file reader.lab4
subdirectory of your personal repo, the other submits a file report.txt
in the lab4
subdirectory of your repo.cd ~/cs151 mkdir lab4You will later put UML diagram files inside.
Post
, Response
, User
and FollowupDiscussion
. Just draw relationship arrows. Pay attention to the multiplicities. Take a photo when you are done. ArrayList<String> list = ... Iterator<String> iter = list.listIterator(); while (iter.hasNext()) { String element = iter.next(); System.out.println(element); }Draw a sequence diagram with an unnamed object representing this code, and objects
list
and iter
. Now the fun begins. Look at the implementation of ArrayList
. The definitition of listIterator
is in line 1008. Skip the first two technical checks. Then draw what it says. (Hint: create)hasNext
. From where to where does it go? Does it do anything else interesting?next
. It calls another technical method . Now draw it! (You can peek inside that method in line 1187. It doesn't call other methods.)iter
? Is it the correct type? Fix it if not.