# Class 19: More Discussion of Exam 1

Back to Discussion of Exam 1; Javadoc. On to Project Discussion.

Held Tuesday, September 26, 2000

Summary

Today we continue our discussion of exam 1 by visiting the latter parts of the exam.

Notes

• Exam 1 returned.
• You may also see me if I didn't include a note to that effect.
• Today, we're going to continue to discuss the exam, particularly part C, since there was some confusion.
• I'll get notes on Part C posted on the Web later this week.
• Are there questions on phase 2 of the project?
• I've decided that I will not be grading homework 1. At this point, I think you've gotten everything you would have out of that assignment.
• Homework 3 is almost ready.

Overview

• Proper citation
• A GCD algorithm in Java
• Orderings and more

## Citations

• All works should have an author and a publisher.
• If you can't determine the author, use Anonymous or the publisher (whichever seems more appropriate).
• If you can't determine the publisher, incldue a note to that effect.
• Because Web pages change, you need to include additional information.
• Date visited.

## GCD

• Recursive
```public static void gcd(int x, int y) {
// The GCD of anything and 0 is that thing
if (x == 0)
return y;
// The GCD of anything and 0 is that thing
else if (y == 0)
return x;
// If y evenly divides x then y is the GCD of x and y
else if ((x % y) == 0)
return y;
else
return gcd(y, x%y);
} // gcd(int,int)
```
• Iterative
```public static void gcd(int x, int y) {
if (x == 0)
return y;
if (y == 0)
return x;
int smaller = y;
int larger = x;
int tmp;
while ((tmp = larger % smaller) != 0) {
larger = smaller;
smaller = tmp;
} // gcd(int,int)
```
• Most of you got 8 and 9.
• Any questions?

## Orderings

• To be held as a discussion.
• One great observation from your exams
• ``Classes are like nouns, interfaces are like adjectives''
• If you have associated data or an implementation of a method, you need a class. Otherwise, an interface should suffice.

## History

Wednesday, 23 August 2000

• Created as a blank outline.

Thursday, 24 August 2000

• Slight reorganization to page design.

Tuesday, 26 September 2000

• Filled in details.

Back to Discussion of Exam 1; Javadoc. On to Project Discussion.

Disclaimer Often, these pages were created "on the fly" with little, if any, proofreading. Any or all of the information on the pages may be incorrect. Please contact me if you notice errors.