This preview shows page 1-2-3-4-5-6-7-8-9-10-11-12-82-83-84-85-86-87-88-89-90-91-92-165-166-167-168-169-170-171-172-173-174-175-176 out of 176 pages.
Slide 1More InheritanceCourse DisplayerCourse Displayer User InterfaceCourse Displayer ClassesAlternative 1: One Course ClassAlternative 2: Two Course ClassesAlternative 3: Three Course ClassesBottom-up vs. Top-down Inheritance HierarchyACourseAbstract classesACourseARegularCourseAFreshmanSeminarCourse InterfaceFreshman Seminar InterfaceInterpreted How?Reusable DesignObjectEditor and IS-APossible OE BugCourse Displayer User Interface (Review)ACourse (Review)ARegularCourse (Review)AFreshmanSeminar (Review)Course Interface (Review)Freshman Seminar Interface (Review)Collection vs. Course Class HierarchyARegularCourseAlternative ARegularCourseAlternative ARegularCourseACourseEquivalent ACourseAlternative ARegularCourseAlternative ARegularCourseCourse List?CourseListACourseList addElementACourseList matchTitleCourse Displayer User InterfaceMain class: ImportsMain class: Main methodMain class: Filling ListMain class: printingA StringHistory ImplementationA Big StringHistory ImplementationNull Overridden MethodA StringHistory ImplementationA Big StringHistory ImplementationAn Erroneous Big StringHistory ImplementationNull Overridden Methodabstract methodsAn Erroneous Big StringHistory ImplementationNull vs. Abstract MethodsAbstract methodAbstract class vs. methodsAnother CourseAlternative ARegularCourseAlternative AFreshmanSeminarAbstract methods vs. InterfacesAbstract methods vs. InterfacesAbstract methods in constructorsAbstract methods in constructorsAbstract methods in constructorsInitializing declarationInitializing declarationsConstant initializationsProcessing of newProcessing of newProcessing of newVisibility of SuperClass MembersAccess control on variables and Inheritance, PackagesAccessing SuperClass VariablesAlternative AFreshmanSeminarAbstract CourseDisplay Abstract CourseAbstract CourseRedefining SuperClass VariablesAlternative AFreshmanSeminarRedeclaring superclass variablesAbstract CourseRe-declaring subclass variablesMultiple ConstructorsAlternative AFreshmanSeminarCode DuplicationConstructor calling ConstructorConstructor calling ConstructorConstructor calling ConstructorConstructor calling ConstructorPossible constructor call semanticsActual SemanticsSolution: Init MethodInit methodsDynamic Dispatch (review)Regular vs. Virtual MethodAbstract Method ExampleFactory Abstract MethodAbstract Course (Review)Accessing SuperClass Variables (Review)Constructor Prints Uninitialized ValuesRedefining SuperClass Variables (Review)Redeclaring superclass variables (Review)ACourseList matchTitle (Review)Constructor calling Constructor (review)Init Method (Review)Allowing Init After ConstructionARegularCourseARegularCourse with InitARegularCourse with InitInit methodsTwo ways to constructParameterized ConstructorsOverloading, Polymorphism, and Dynamic dispatchOverloading, Polymorphism, and Dynamic dispatchPolymorphism vs. Overloading and Dynamic DispatchPolymorphism vs. Overloading and Dynamic DispatchManual instead of Dynamic DispatchCan we get rid of manual dispatch/instanceof?Cannot always get rid of manual dispatch/instancofprintHeader() in ARegularCourseprintHeader() in AFreshmanSeminarShould not always get rid of manual dispatch/instancofCannot always get rid of manual dispatch/instancofFilling Course List InteractivelyGrammar: If-Else StatementGrammar: EnglishFilling Course List InteractivelyCourse Input. vs. Title Input StructureGrammarGrammar-based ConceptsDeriving Terminals from a Non-TerminalMain class: Previous Main methodMain class: New Main methodInteractive FillingProcessing Course SequenceProcessing CourseProcessing FreshmanSeminarProcessing Regular CourseProcessing Course (Review)Processing FreshmanSeminar (Review)Parser StructureAbstract Class Implementing InterfaceARegularCourseEquivalent ARegularCourseExtra SlidesMultiple InitsSome SuperTypes in ExamplesAbstract Classes in java.util?Abstract Classes in java.utilPolymorphism vs. Overloading and Dynamic DispatchPolymorphism vs. Overloading and Dynamic DispatchOverloading vs. dynamic dispatchSlide 152Slide 153Slide 154Physical and Computer InheritanceDifferent Types== for ObjectsAbstract CourseAnother CourseAbstract methodCourse Displayer User InterfaceMain class: Filling ListJava Vectors, Array Lists and IteratorsVectors (java.util.Vector)Important Methods of Class VectorMethods of Interface Enumeration (java.util.Enumeration)Methods of Interface Enumeration (java.util.Enumeration)Using Vector DirectlyEncapsulating VectorEncapsulating VectorAdapter PatternAdapter PatternParser StructureSlide 174Alternative ARegularCourseAlternative AFreshmanSeminarCOMP 401ADVANCED INHERITANCEInstructor: Prasun Dewan2MORE INHERITANCETop-Down vs Bottom-Up InheritanceAbstract ClassesVariable InitializationConstructor Invocation in Same ClassConstructor Invocation in Super ClassInit MethodsAbstract MethodsDynamic Dispatch3COURSE DISPLAYERUser input course titleProgram displays course number, if offered.4COURSE DISPLAYER USER INTERFACE5COURSE DISPLAYER CLASSESCourse ListMatches titleMain classCreates course list and adds course instancesPrints coursesCombines dept and number into one stringCourse class(es)?6ALTERNATIVE 1: ONE COURSE CLASS CoursePropertiesTitle, Dept, NumberVariables:Title, Dept, NumberNot appropriate for freshman seminarNumber is not a variable!7ALTERNATIVE 2: TWO COURSE CLASSESRegular Course PropertiesTitle, Dept, NumberVariables:Title, Dept, NumberFreshman SeminarPropertiesTitle, Dept, NumberVariables:Title, DeptConstantNumberBut some variables/properties are commonTitle, Dept8ALTERNATIVE 3: THREE COURSE CLASSESAdditional class for common variablesTitle, DeptTwo course classes inherit from itRegular course adds number variable and property Freshman seminar adds number constant and property9BOTTOM-UP VS. TOP-DOWN INHERITANCE HIERARCHYAStringHistoryAStringSetAStringDatabaseAFreshmanSeminar ARegularCourseACourseNot instantiated10ACOURSEShould not be instantiatedCannot have course without a number!Always some subclass is instantiatedDeclared as abstract class11ABSTRACT CLASSESJava ensures they are not instantiatedAbstract vs. regular class Car vs. Honda Accord, Mammal vs. Homo Sapiens,12ACOURSEpackage courses;public abstract class ACourse {String title, dept;public ACourse (String theTitle, String theDept) {title = theTitle;dept = theDept;}public String getTitle() {return
View Full Document