# Lecture 14: Review of Term (So FAR) - PowerPoint PPT Presentation

1 / 5

Lecture 14: Review of Term (So FAR). Methods.

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.

Lecture 14: Review of Term (So FAR)

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

## Lecture 14:Review of Term (So FAR)

### Methods

public classSum {private intval;Sum(intv) { val = v; }Sum() {this(0); }void inc(inti) {val += i; }void inc(Sum s) {val += s.val; }public static void main(String[] args) {Sumsq = new Sum();SumsumSq = new Sum(); for (inti = 0; i < 4; i++) {sq.inc((2 * i) + 1);sumSq.inc(sq);System.out.println(sq.val); }System.out.println(sumSq.val);}

}

### Methods

public classSumTwoextends Sum {SumTwo(intv) { super(v); }void inc(inti, intj) {inc(i+ j); }public static void main(String[] args) {SumnotFib = new SumTwo(0);intfst = 0;intsnd = 1; for (inti = 0; i < 4; i++) {notFib.inc(fst, snd);inttmp = fst + snd;fst = snd;snd = tmp; }System.out.println(notFib.val);}

}

### For Midterm

• You can use on this midterm:

• You can always use yourtextbook & notes

• Printout of slides IF has notes on that day's slides

• At the same time, you may NOT use:

• Computer, calculator, cell phone, or similar

• Copies of daily activities and/or solutions

• Friends, Romans, countrymen or their ears

### How to Prepare for Midterm

DO

DON'T

• Make cheat sheets for the test

• Review how parts of Java work

• Add post-its to important pages

• Memorize

• Drink case of 40s before test

• Use post-its as clothing