1 / 5

Lecture 14: Review of Term (So FAR)

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

ronny
Download Presentation

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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  2. 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);} }

  3. 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);} }

  4. 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

  5. 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

More Related