# Exam 1

### Due: 9am Friday October 15, 2021

Note that this is released after class Wednesday, and is due before class, not due in the evening.

This page details a take-home exam that you will complete over the next few days. You can’t communicate with anyone about the content of the assignment until you receive your grade. You can message us privately on Piazza, but the course staff will not give programming advice or answer most questions about the problems. If you have technical trouble creating a screencast (detailed below) feel free to reach out for assistance.

Do not use any online service other than Piazza to ask questions about the assignment. Do not search for, solicit, or use solutions to the problems that you find elsewhere for the exam. These are all violations of academic integrity that students have committed on exams like this in the past.

You can make use of any course notes, online resources about Java and its libraries, Java tools, and so on to complete the exam, including re-using code from class notes.

You can review the grading policy for exams in the syllabus. You will complete the programming task below and submit your work to the exam1 Gradescope assignment.

Submission checklist (see long descriptions below for full details):

• ExamplesMethods.java containing methods from Task 1
• transcript-methods.txt containing the results of running your examples for Task 1
• ExamplesTweets.java containing your modifications as described below
• transcript-tweets.txt containing the results of running your examples for Task 2
• explanation.mp4 (or another video extension) that has your screencast for Task 3

Your submission will be graded after the deadline; there are no pre-deadline check-offs for exams. You should test thoroughly yourself to make sure your program works as expected.

## Clarifications

I don’t see the transcript.txt files in the starter code. Should I create them?

Yes, you should create them.

Can I use a Java feature/library/method that we haven’t covered in class?

Yes, though you shouldn’t need to.

I can’t get my code to run on my computer.

Try using the lab machines, which have the correct setup. Also try reviewing the previous public Piazza posts, which have lots of advice about fixing build situations. Also make sure that your code doesn’t have a bug before you blame your computer or ./run!

Can I submit multiple times until the deadline?

Yes, we will grade the last submission you make before the deadline.

You can find the starter code in this repository https://github.com/ucsd-cse11-f21/cse11-exam1-starter.

In the ExamplesMethods class, you will use the design recipe to write two methods:

• ringArea, which takes two doubles representing the radii of two concentric circles and returns the area of the ring between the two circles. Recall that the area of a circle is given by πr2. You can use 3.1415926 as an approximation of π, or Math.PI.

You can assume the radii are greater than 0.

• rotate, which takes a String called str and an int called n produces a String with the first n characters of str removed from the beginning and added at the end. If the string is shorter than n characters, return the original string. For example, rotate("Hello", 3) would produce "loHel".

Note that it’s fine to add more methods than what we’ve listed, but these two methods must appear as described.

Note that you should use the full design recipe – include enough examples to convince yourself the method works! If you have a question about an interesting input case, try it out and justify why the answer is OK.

The file ExamplesTweets.java has two classes, User and Tweet, which are a partial solution for the same program as in PA2.

• A new class called Date that represents a particular calendar day (reminder that you can use code and ideas from problem sessions for this)
• A new field on Tweet that represents the day the Tweet was posted, including any needed updates to the constructor
• A new method on Tweet called before that takes another Tweet and returns true if this Tweet was posted strictly before the Tweet given as an argument.
• The following examples for the before method:
• tweetExample1 – Two different Tweets posted on different months in the same year that returns false
• tweetExample2 – Two different Tweets posted on different days in the same month and same year that returns true
• tweetExample3 – The same Tweet used as both this and as the argument to before.
• tweetExample4 – Two different Tweets posted in different years, with the this Tweet having an earlier month and day than the argument, and that returns false

You can make up any example Tweets you like for input data (they don’t have to be real-world Tweets)

You will record a short video of no more than 5 minutes. Include:

• Show only your face and a picture ID (your student ID is preferred but any picture ID with your name on it will work) for a few seconds at the beginning. You don’t have to be on camera the whole time, though it’s fine if you are. Just a brief confirmation that it’s you creating the video/doing the work attached to the work itself is what we want. If you do not have a webcam, take a picture of yourself (and your picture ID) with your phone and display that picture at the start of your screen share.
• Choose two examples for your rotate method, one where the string is shorter than n, and one where it is longer. Highlight the examples, and for each, show which return statement in your program runs, and what value is returned by that statement.
• Highlight the example you wrote for tweetExample2. Highlight all of the lines of code that evaluate when that example runs; mark those lines with a comment at the end of the line as you go.

An example of what your video should look like when doing this kind of explanation is here:

• Keep your videos under 5 minutes; videos even a second over 5 minutes will get a 1, this is to ensure we can grade them promptly. To ensure you stay under 5 minutes, make sure to only explain what is described above, and do a few practices or make a script before you start recording.