DOC PREVIEW
UNC-Chapel Hill COMP 401 - Advanced Inheritance

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.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

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 INHERITANCETop-Down vs Bottom-Up InheritanceAbstract ClassesVariable InitializationConstructor Invocation in Same ClassConstructor Invocation in Super ClassInit MethodsAbstract MethodsDynamic Dispatch3COURSE DISPLAYERUser input course titleProgram displays course number, if offered.4COURSE DISPLAYER USER INTERFACE5COURSE DISPLAYER CLASSESCourse ListMatches titleMain classCreates course list and adds course instancesPrints coursesCombines dept and number into one stringCourse class(es)?6ALTERNATIVE 1: ONE COURSE CLASS CoursePropertiesTitle, Dept, NumberVariables:Title, Dept, NumberNot appropriate for freshman seminarNumber is not a variable!7ALTERNATIVE 2: TWO COURSE CLASSESRegular Course PropertiesTitle, Dept, NumberVariables:Title, Dept, NumberFreshman SeminarPropertiesTitle, Dept, NumberVariables:Title, DeptConstantNumberBut some variables/properties are commonTitle, Dept8ALTERNATIVE 3: THREE COURSE CLASSESAdditional class for common variablesTitle, DeptTwo course classes inherit from itRegular course adds number variable and property Freshman seminar adds number constant and property9BOTTOM-UP VS. TOP-DOWN INHERITANCE HIERARCHYAStringHistoryAStringSetAStringDatabaseAFreshmanSeminar ARegularCourseACourseNot instantiated10ACOURSEShould not be instantiatedCannot have course without a number!Always some subclass is instantiatedDeclared as abstract class11ABSTRACT CLASSESJava ensures they are not instantiatedAbstract 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

UNC-Chapel Hill COMP 401 - Advanced Inheritance

Documents in this Course
Objects

Objects

36 pages

Recursion

Recursion

45 pages

Load more
Download Advanced Inheritance
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Advanced Inheritance and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Advanced Inheritance 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?