Download presentation
Presentation is loading. Please wait.
Published byVirginia James Modified over 8 years ago
1
SE1011 Week 8, Class 2 Today Return Half Exam 3 (I have it with me) Object Oriented Programming Details Null references (as acting objects and arguments) Refactoring code Designing Code Muddiest Point SE-1011 Slide design: Dr. Mark L. Hornick Instructor: Dr. Yoder 1
2
“How-To Register” Info Session! Who: Anyone who wants to know how to register for classes for the Winter Quarter. What: A “How-To Register” Info Session with step- by-step instructions on how to register for classes. Registration for the winter quarter is coming up very shortly, and we want to make sure you feel prepared! When: You pick the day: Monday, November 2 nd, 1:00-1:50 p.m., or Friday, November 6 th, 12:00-12:50 p.m. Where: CC 53 2
3
Muddiest Point I understood most of today's concepts, but would like to go over static classes again really quickly just a refresher. [Coming up soon]static classes The origin of an xy plane falls into a pig pen. Now that's a muddy point.joke debuggingdebugger what does the memory diagram look like when you instantiate an object with null?null aren't they still equal if they're both null?null How to debug a program that requires user input.debugger 3 Discussed at start. Discussed during this class. [Instructor answer to the question]
4
Muddiest Point how to use this.this. & other. Does || work the same way as && as a short circuit operator? So if(true || ) will it go on or will it crash?|| short-circuit Not exactly a muddy point, but is there a sheet that has a bunch of useful hotkeys to use in intellij? (For example the ctrl + / for commenting out highlighted things) [Help->Default Keymap Reference]sheetintelliJ hotkeys how to use "this." & "other."this. & other. Should we have the comparator in the complex class? [Wait until Data Structures (CS2852)]Comparator 4 Discussed at start. Discussed during this class. [Instructor answer to the question]
5
NullPointerExceptions 5 main(…) 85638 Complex real double imag double real 3.0 0.0 Complex ref r3 85638 Complex ref n null Complex ref prod public … void main(…) { … Complex n = null; Complex r3 = new Complex(3); prod = n.multBy(r3); … }
6
NullPointerExceptions 6 main(…) 85638 Complex real double imag double real 3.0 0.0 Complex ref this 85638 Complex(double real, double imag) Complex ref r3 85638 Complex ref n null Complex ref other null Complex ref prod public … void main(…) { … Complex n = null; Complex r3 = new Complex(3); prod = r3.multBy(n); … } public Complex multBy(Complex other) { // HERE Complex result = new Complex(); result.real = this.real * other.real - this.imag * other.imag; result.imag = this.real * other.imag + this.imag * other.imag; return result; }
7
NullPointerExceptions 7 main(…) 85638 Complex real double imag double real 3.0 0.0 Complex ref this 85638 Complex(double real, double imag) Complex ref r3 85638 Complex ref n null Complex ref prod public … void main(…) { … Complex n = null; Complex r3 = new Complex(3); prod = r3.multBy(n); … } public Complex multBy(Complex other) { Complex result = new Complex(); // HERE result.real = this.real * other.real - this.imag * other.imag; result.imag = this.real * other.imag + this.imag * other.imag; return result; } 85642 Complex real double imag double Complex ref result 85642 Complex ref other null 0.0
8
SE-1011 Slide design: Dr. Mark L. Hornick Instructor: Dr. Yoder 8
9
Acknowledgement This course is based on the text Introduction to Programming with Java by Dean & Dean, 2 nd Edition SE-1011 Slide design: Dr. Mark L. Hornick Instructor: Dr. Yoder 9
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.