Lecture 40, CS 302-6, December 07 1. Various things a. Program 4 i. Grading: 1. 15% Object oriented structure, 10% Commenting ii. Tip – figuring out if a move is valid and flipping the pieces is probably the toughest part. If you get stuck, try working on the save and load options iii. Partners - by Friday, 12/9 b. Extra consulting hours start Friday, continue through weekend c. Final exam info posted i. Sample questions ii. Last spring’s exam 2. Review: a. Building our own exceptions i. Extends clause ii. public class <className> extends <className> iii. Extend either Exception or Runtime Exception, depending on whether you want it to be checked or unchecked. b. Class Hierarchy (note – not on final) i. Inheritance – relationship between classes ii. Subclasses/children and Superclasses/parents iii. The role that extends plays in this – defining a subclass c. Substitution principle i. If your code calls for a superclass, you can use one of its subclasses. d. More specific classes can still use methods from their parent classes 3. Overriding and Overloading a. Overriding methods i. Defining the same method in a subclass as a superclass – if we call it from an object of the subclass, it will use the subclass version b. Overloading i. Same method name, different parameters ii. Overloading constructors iii. Overloading methods 4. super a. Another reserved word - super b. Used for calling methods, constructors, and accessing variables from superclass c. Use to access methods from super class that are overridden i. Syntax: super.method(params); ii. Things to be careful about – if calling the same method from the superclass from within a method in the subclass, make sure to use the super keyword – otherwise, you’ll probably end up in an infinite loop iii. Superclass constructors 1. Can call the superclass constructor from within the subclass constructor 2. Syntax: super(params); 5. More vocab: a. Dynamic method lookup i. Method calls are determined by type of object, not variable b. Polymorphism i. Ask different objects to carry out same task – each does it in its own way 6. Example – Car, Vehicle, Bike, VehicleTester 7. Note – material from this part of chapter 9 will not be on the exam a. It will, however, come in handy with the extra credit for P4 8. Homework – For Wednesday – Finish ch 9