Discussion 4 handout
Group members (names & NetIDs)
Objectives
- Review skills covered by the first prelim exam
- (optional) Practice file I/O, string tokenization, and exception handling
Overview
Our exam study guide includes a thorough list of skills that you should be able to perform at this point in the course, divided into 6 categories:
- Procedural programming in Java
- Compile-time and run-time
- Classes in Java
- Testing
- Object-oriented programming in Java
- Exceptions
TAs have written questions that exercise these skills and will select several to review during section. Work with your group to answer the questions as they are presented, recording your work and final answer on your worksheet. Submit this worksheet as usual at the end of section (it is okay if your section does not get through five different problems).
Problem 1
Problem 2
Problem 3
Problem 4
Problem 5
Submission
- Open the assignment page for “Discussion activity 4” in CMSX
- [Recorder] Find the “Group Management” section and invite each group member
- [Others] Refresh the page and accept your invitation
- [Recorder] Take a picture of your work and save as either a JPEG or a PDF file named “discussion_responses” (you do not need to submit your test code). After all invitations have been accepted, upload your picture along with your code as your group’s submission.
- Recommended scanning apps: Microsoft Office Lens, Adobe Scan, Genius Scan, Evernote Scannable
Ensure that your group is formed and your work submitted before the Friday evening deadline.
Tips and reminders
- Discussion is not a race. Focus on the current activity being facilitated by your TA and engage your whole group to propose and explain ideas.
- Elect a recorder to maintain the “master” copy of your work (others are still encouraged to jot down ideas on scratch paper). Rotate this position each week.
- It is a violation of academic integrity to credit someone for work if they were not present when the work was done, and the whole group is accountable. Your CMS group must only include classmates who attended section with you on that day. Remember that our participation policies accommodate occasional absences without penalty.
- It is your individual responsibility to ensure that you are grouped on CMS and that your group’s work is submitted before the deadline. Log into CMS the day after section to ensure that everything is in order, and contact your groupmates if not. It would be prudent for multiple members to photograph the group’s work.
- Only one group member (typically the recorder) needs to upload a submission. But their submission must not be uploaded until after all group members have confirmed their membership in CMS (contact your TA if you have trouble grouping in CMS).
Challenge problem
If your entire group finishes early and are looking for more practice with this material, try completing this additional task. To be clear, we are not expecting anyone to submit work on challenge problems to CMSX, nor will your TA have time to discuss them in section. But you are welcome to discuss them on Ed or to bring questions and ideas to office hours.
Preparation: Demo code and word hunt files
Please download dis04-release.zip, extract it to a known location on your computer, and open it as a project in IDEA.
The class ReadLineDemo
should be similar to examples from lecture.
Task 1: Word hunt
One group member, the driver, should open “WordHunt.java” in their “dis04” IDEA project. They will be responsible for writing and running code. The other group members will serve as navigators, double-checking what is typed and suggesting solution structures to efficiently achieve the desired goal.
Implement WordHunt.main()
to perform the following task:
- Read 13 lines of text from the file “index.txt” (in the project’s root directory).
- On the 13th line, read 37 space-delimited entries.
- Extract a filename prefix, line number, and word number (delimited by hyphens) from the 37th entry.
- Append “.txt” to the filename prefix and open the corresponding file. Read the number of lines specified by the index entry, then read the specified number of words within that line.
- Report the last word read.
Run WordCount
and record both the index entry and the final word on your worksheet.