Basic Class Diagrams. Class Diagrams, cont d. Class Diagrams, cont d. Car. Car. Car. What does the minus sign here mean?
|
|
- Reynard Stewart
- 5 years ago
- Views:
Transcription
1 Class #02: Inheritance and Object-Oriented Design Software Design II (CS 220): M. Allen, 23 Jan. 18 Basic Class Diagrams Describes a class and how it can be used properly Sketch of properties and behaviors of objects in the class No extra details about how they actually work Class Name attributes (instance variables) operations (methods) + (String, int) 2 Attributes What does the minus sign here mean? class has two simple attributes, storing basic facts about each individual car Each different object instance in a program will have its own version of these different attributes + (String, int) class instance variables both have private access Store information, but that info cannot be accessed or altered from anywhere outside the class How do we read or write to such private variables? + (String, int) 3 4 1
2 Class Methods What does the plus sign mean here? Update methods Change something about state of an object These return void (take an action but don t give output) Query methods Tell us about object state non-void return: actually give us some info back + (String, int) These methods all have public access Can be used outside of the class (by other class code) Allows programmer to control exactly how variables are changed, and what information is revealed by the class + (String, int) 5 6 Code for a Lot Management Application Constructor Constructor method Used to create an object Has same name as class Has no return type in front Almost always public (WHY?) This constructor takes two parameters as input + (String, int) Manny Citron s Used s wants you to write an inventory-management program for them It needs to track their current stock of vehicles Needs to add and remove vehicles from the stock 7 8 2
3 Object-Oriented Design The Lot class uses instance variables of the class type It is an aggregate class, made up of other class objects We can sketch relationships between class diagrams Diamond arrow signifies a used by relationship Also known as a has-a relationship, in the sense that the Lot class has some instances as part of its own specification car1 car2 Lot + Lot() + add() + remove() + void prints() <<attributes>> <<methods>> A Hitch: Changing Problem Specification Manny soon realizes that your basic class isn t enough for his needs Also sells commercial vehicles (trucks/vans), with different carrying capacities (1/5/10 ton, ) 9 10 One Solution: Create a New Class Another Solution + (String, int) Truck int capacity + Truck(String, int, int) + void setcapacity(int) + int getcapacity() We could just duplicate the class for the Truck class (and maybe more), adding in the features we need A number of drawbacks: 1. Code repetition: we duplicate our work in multiple classes 2. Harder to write general-purpose code: our car-lot code will have to handle Truck and objects, and we may not know which ones we are going to get at any specific point (e.g. when a new one is added to the stock) Instead, we will use inheritance structures
4 Common Features in Classes Certain types of objects have things in common s/trucks/motorcycles Savings/checking/investment accounts In Java, such similarities are exploited by inheritance Code can be made simpler and more useful Similarities are written into the super-class (parent) Each sub-class (child) extends the parent Inherits all similarities, and can have particular differences of its own Child inherits methods and variables If these things are private, then they are not accessible to child If they are public (or protected), then the child can directly access them as if they were its very own Inheritance in Pictures and in Code Inheritance can be represented as a diagram, with openheaded arrows from children to parents Each child is a more specific kind of parent object This is called an is-a relationship, since each, for example, is actually a kind of Vehicle, too Vehicle Truck class Vehicle { class extends Vehicle { // data and methods // more data and methods class Truck extends Vehicle { // more data and methods Object Diagrams for Inheritance Implementing the Vehicle Class Vehicle - String makemodel - int mileage + Vehicle(String, int) + (String, int) Truck int capacity + Truck(String, int, int) + void setcapacity(int) + int getcapacity() public class Vehicle { private String makemodel; private int mileage; public Vehicle( String mod, int miles ) { makemodel = mod; mileage = miles; public void setmakemodel( String s ) { makemodel = s; public void setmileage( int m ) { mileage = m; public String getmakemodel() { return makemodel; public int getmileage() { return mileage; Other than the necessary Vehicle() constructor, this is identical to the code that was originally part of the class If the class doesn t need to add any more features, then there we won t bother to do so
5 The Sub-Class Implementing the Class extends Vehicle for inheritance needs own constructor, but nothing else! + (String, int) Every other method and variable it needs can be inherited directly from the Vehicle class, without need of repetition public class extends Vehicle { public ( String mod, int miles ) { super( mod, miles ); The () constructor simply takes its inputs and passes them along to the super() Vehicle constructor, which itself then writes their values to the instance variables Constructors and the super Command All methods and variables of a parent are inherited, except for the constructor Main reason: constructor must have same name as class itself Parent constructor must be called first to instantiate any necessary attribute variables, before child constructor can do any necessary work of its own The child runs its own constructor, and if it wants to use the parent constructor it uses the super reference super() is the parent constructor super.methodname() runs a method from the parent explicitly (often optional, as long as there is no other method with the same name, due to over-riding, etc.) Implementing the Truck Class Truck has extra instance variable Constructor runs super() to set common variables, then saves extra capacity variable locally public class Truck extends Vehicle { private int capacity; public Truck( String mod, int miles, int cap ) { super( mod, miles ); capacity = cap; /* post: result == makemodel */ public void setcapacity( int c ) { capacity = c; public int getcapacity() { return capacity; Has its own particular methods, unique to Truck class
6 This Week Topic: Inheritance and polymorphism Class meetings: Monday Thursday: regular classroom Friday: in the CS Lab (16 Wing) Optional Reading: Chapter 5 & 6 in text Office Hours: Wing 210 Monday/Wednesday/Friday, 10:00 AM 11:00 AM Tuesday/Thursday, 1:30 PM 3:00 PM 21 6
Review: Object Diagrams for Inheritance. Type Conformance. Inheritance Structures. Car. Vehicle. Truck. Vehicle. conforms to Object
Review: Diagrams for Inheritance - String makemodel - int mileage + (String, int) Class #3: Inheritance & Polymorphism Software Design II (CS 220): M. Allen, 25 Jan. 18 + (String, int) + void
More information} Evaluate the following expressions: 1. int x = 5 / 2 + 2; 2. int x = / 2; 3. int x = 5 / ; 4. double x = 5 / 2.
Class #10: Understanding Primitives and Assignments Software Design I (CS 120): M. Allen, 19 Sep. 18 Java Arithmetic } Evaluate the following expressions: 1. int x = 5 / 2 + 2; 2. int x = 2 + 5 / 2; 3.
More informationSearching for Information. A Simple Method for Searching. Simple Searching. Class #21: Searching/Sorting I
Class #21: Searching/Sorting I Software Design II (CS 220): M. Allen, 26 Feb. 18 Searching for Information Many applications involve finding pieces of information Finding a book in a library or store catalogue
More informationTwo Types of Types. Primitive Types in Java. Using Primitive Variables. Class #07: Java Primitives. Integer types.
Class #07: Java Primitives Software Design I (CS 120): M. Allen, 13 Sep. 2018 Two Types of Types So far, we have mainly been dealing with objects, like DrawingGizmo, Window, Triangle, that are: 1. Specified
More informationReview: Using Imported Code. What About the DrawingGizmo? Review: Classes and Object Instances. DrawingGizmo pencil; pencil = new DrawingGizmo();
Review: Using Imported Code Class #06: Objects, Memory, & Program Traces Software Engineering I (CS 120): M. Allen, 30 Jan. 2018 ; = new ();.setbackground( java.awt.color.blue );.setforeground( java.awt.color.yellow
More information} Each object in a Java program has an identifier (name) } This includes:
Class #05: More about Objects and Methods Software Design I (CS 120): M. Allen, 11 Sept. 2018 Important Java Syntax I: Identifiers Each object in a Java program has an identifier (name) This includes:
More informationInheritance. Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L
Inheritance Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L 9.1 9.4 1 Inheritance Inheritance allows a software developer to derive
More informationReview: Classes and Object Instances. Review: Creating an Object. Using Multiple Objects. DrawingGizmo pencil; pencil = new DrawingGizmo();
Review: Classes and Object Instances ; = new (); Class #05: Objects, Memory, & Program Traces Software Engineering I (CS 120): M. Allen, 12/13 Sept. 17 We are working with both a class () and an object
More informationConverting Collections to Arrays. A Bad Approach to Array Conversion. A Better Approach to Array Conversion. public Object[] toarray();
Converting Collections to Arrays Every Java collection can be converted to an array This is part of the basic Collection interface The most elementary form of this method produces an array of base-type
More informationCSE 113 A. Announcements - Lab
CSE 113 A February 21-25, 2011 Announcements - Lab Lab 1, 2, 3, 4; Practice Assignment 1, 2, 3, 4 grades are available in Web-CAT look under Results -> Past Results and if looking for Lab 1, make sure
More informationCS11 Introduction to C++ Fall Lecture 7
CS11 Introduction to C++ Fall 2012-2013 Lecture 7 Computer Strategy Game n Want to write a turn-based strategy game for the computer n Need different kinds of units for the game Different capabilities,
More informationCOSC 121: Computer Programming II. Dr. Bowen Hui University of Bri?sh Columbia Okanagan
COSC 121: Computer Programming II Dr. Bowen Hui University of Bri?sh Columbia Okanagan 1 Quick Review Inheritance models IS- A rela?onship Different from impor?ng classes Inherited classes can be organized
More informationBuilding custom components IAT351
Building custom components IAT351 Week 1 Lecture 1 9.05.2012 Lyn Bartram lyn@sfu.ca Today Review assignment issues New submission method Object oriented design How to extend Java and how to scope Final
More informationWeek 2. TA Lab Consulting - See schedule (cs400 home pages) Peer Mentoring available - Friday 8am-12pm, 12:15-1:30pm in 1289CS
ASSIGNMENTS h0 available and due before 10pm on Monday 1/28 h1 available and due before 10pm on Monday 2/4 p1 available and due before 10pm on Thursday 2/7 Week 2 TA Lab Consulting - See schedule (cs400
More informationSoftware Design and Analysis for Engineers
Software Design and Analysis for Engineers by Dr. Lesley Shannon Email: lshannon@ensc.sfu.ca Course Website: http://www.ensc.sfu.ca/~lshannon/courses/ensc251 Simon Fraser University Slide Set: 2 Date:
More informationC++ Important Questions with Answers
1. Name the operators that cannot be overloaded. sizeof,.,.*,.->, ::,? 2. What is inheritance? Inheritance is property such that a parent (or super) class passes the characteristics of itself to children
More informationProgramming Exercise 14: Inheritance and Polymorphism
Programming Exercise 14: Inheritance and Polymorphism Purpose: Gain experience in extending a base class and overriding some of its methods. Background readings from textbook: Liang, Sections 11.1-11.5.
More informationUniversity of British Columbia CPSC 111, Intro to Computation Jan-Apr 2006 Tamara Munzner
University of British Columbia CPSC 111, Intro to Computation Jan-Apr 2006 Tamara Munzner Inheritance II Lecture 23, Thu Mar 30 2006 based on slides by Kurt Eiselt http://www.cs.ubc.ca/~tmm/courses/cpsc111-06-spr
More informationCS 251 Intermediate Programming Inheritance
CS 251 Intermediate Programming Inheritance Brooke Chenoweth University of New Mexico Spring 2018 Inheritance We don t inherit the earth from our parents, We only borrow it from our children. What is inheritance?
More informationCS18000: Problem Solving And Object-Oriented Programming
CS18000: Problem Solving And Object-Oriented Programming Data Abstraction: Inheritance 7 March 2011 Prof. Chris Clifton Data Abstraction Continued Abstract data type provides Well-defined interface Separation
More informationInheritance. COMP Week 12
Inheritance COMP1400 - Week 12 Uno Game Consider the card game Uno: http://en.wikipedia.org/wiki/uno_(card_game) There are 6 kinds of cards: number cards draw two skip reverse wild wild draw four Game
More informationFinal Exam CS 251, Intermediate Programming December 10, 2014
Final Exam CS 251, Intermediate Programming December 10, 2014 Name: NetID: Answer all questions in the space provided. Write clearly and legibly, you will not get credit for illegible or incomprehensible
More informationIntroduction to Computer Science II CS S-10 Inheritance
Introduction to Computer Science II CS112-2012S-10 Inheritance David Galles Department of Computer Science University of San Francisco 10-0: Classes Want to create a bunch of classes for a real estate
More informationCMSC202 Computer Science II for Majors
CMSC202 Computer Science II for Majors Lecture 14 Polymorphism Dr. Katherine Gibson Last Class We Covered Miscellaneous topics: Friends Destructors Freeing memory in a structure Copy Constructors Assignment
More informationJava Object Oriented Design. CSC207 Fall 2014
Java Object Oriented Design CSC207 Fall 2014 Design Problem Design an application where the user can draw different shapes Lines Circles Rectangles Just high level design, don t write any detailed code
More informationProject 1 Balanced binary
CMSC262 DS/Alg Applied Blaheta Project 1 Balanced binary Due: 7 September 2017 You saw basic binary search trees in 162, and may remember that their weakness is that in the worst case they behave like
More informationEECS 211 Lab 8. Inheritance Winter Getting the code. Inheritance. General Idea. An Example
EECS 211 Lab 8 Inheritance Winter 2018 In this week s lab, we will be going over inheritance, and doing some more practice with classes. If you have any lingering questions during the lab, don t hesitate
More informationLecture 3. COMP1006/1406 (the Java course) Summer M. Jason Hinek Carleton University
Lecture 3 COMP1006/1406 (the Java course) Summer 2014 M. Jason Hinek Carleton University today s agenda assignments 1 (graded) & 2 3 (available now) & 4 (tomorrow) a quick look back primitive data types
More informationObjects and Classes. Amirishetty Anjan Kumar. November 27, Computer Science and Engineering Indian Institue of Technology Bombay
Computer Science and Engineering Indian Institue of Technology Bombay November 27, 2004 What is Object Oriented Programming? Identifying objects and assigning responsibilities to these objects. Objects
More informationArrays Classes & Methods, Inheritance
Course Name: Advanced Java Lecture 4 Topics to be covered Arrays Classes & Methods, Inheritance INTRODUCTION TO ARRAYS The following variable declarations each allocate enough storage to hold one value
More informationCompSci 125 Lecture 20. Inheritance: Introduction, Overrides UML: Introduction to Class Diagrams
CompSci 125 Lecture 20 Inheritance: Introduction, Overrides UML: Introduction to Class Diagrams Announcements Introduction to Inheritance Inheritance: Motivation Software is expensive Wish to define a
More informationAnd Even More and More C++ Fundamentals of Computer Science
And Even More and More C++ Fundamentals of Computer Science Outline C++ Classes Friendship Inheritance Multiple Inheritance Polymorphism Virtual Members Abstract Base Classes File Input/Output Friendship
More informationMaterial: Specification and Reasoning. Book: Logic in Computer Science, M.Huth, M.Ryan, Cambridge University Press. Lectures mondays here,
Material: Specification and Reasoning Lectures mondays here, Lecturer Pasquale Malacaria CS/428 Labs thursdays with Dino DiStefano Book: Logic in Computer Science, M.Huth, M.Ryan, Cambridge University
More informationCoverage of Part 2. A Brief Introduction to Java for C++ Programmers: Part 2. import: using packages
Coverage of Part 2 A Brief Introduction to Java for C++ Programmers: Part 2 ENGI 5895: Software Design Andrew Vardy Faculty of Engineering & Applied Science Memorial University of Newfoundland This second
More informationCOMP 110/L Lecture 19. Kyle Dewey
COMP 110/L Lecture 19 Kyle Dewey Outline Inheritance extends super Method overriding Automatically-generated constructors Inheritance Recap -We talked about object-oriented programming being about objects
More informationCS61BL. Lecture 1: Welcome to CS61BL! Intro to Java and OOP Testing Error-handling
CS61BL Lecture 1: Welcome to CS61BL! Intro to Java and OOP Testing Error-handling About me Name: Edwin Liao Email: edliao@berkeley.edu Office hours: Thursday 3pm - 5pm Friday 11am - 1pm 611 Soda Or by
More informationReview: Trees Binary Search Trees Sets in Java Collections API CS1102S: Data Structures and Algorithms 05 A: Trees II
05 A: Trees II CS1102S: Data Structures and Algorithms Martin Henz February 10, 2010 Generated on Wednesday 10 th February, 2010, 10:54 CS1102S: Data Structures and Algorithms 05 A: Trees II 1 1 Review:
More informationEncapsulation. Administrative Stuff. September 12, Writing Classes. Quick review of last lecture. Classes. Classes and Objects
Administrative Stuff September 12, 2007 HW3 is due on Friday No new HW will be out this week Next Tuesday we will have Midterm 1: Sep 18 @ 6:30 7:45pm. Location: Curtiss Hall 127 (classroom) On Monday
More informationCOP 3330 Final Exam Review
COP 3330 Final Exam Review I. The Basics (Chapters 2, 5, 6) a. comments b. identifiers, reserved words c. white space d. compilers vs. interpreters e. syntax, semantics f. errors i. syntax ii. run-time
More informationObject Orientated Programming Details COMP360
Object Orientated Programming Details COMP360 The ancestor of every action is a thought. Ralph Waldo Emerson Three Pillars of OO Programming Inheritance Encapsulation Polymorphism Inheritance Inheritance
More informationMore on Inheritance. Interfaces & Abstract Classes
More on Inheritance Interfaces & Abstract Classes Java interfaces A Java interface is used to specify minimal functionality that a client requires of a server. A Java interface contains: method specifications
More informationObject Oriented Programming is a programming method that combines: Advantage of Object Oriented Programming
Overview of OOP Object Oriented Programming is a programming method that combines: a) Data b) Instructions for processing that data into a self-sufficient object that can be used within a program or in
More informationInheritance. For example, to zoom in on the deer family (cervid), we could make a tree like the following.
Inheritance The concept of inheritance is one of the key features of an object-oriented programming language. Inheritance allows a programmer to define a general class, and then later define more specific
More informationLogistics. Final Exam on Friday at 3pm in CHEM 102
Java Review Logistics Final Exam on Friday at 3pm in CHEM 102 What is a class? A class is primarily a description of objects, or instances, of that class A class contains one or more constructors to create
More informationLecture 10: building large projects, beginning C++, C++ and structs
CIS 330: / / / / (_) / / / / _/_/ / / / / / \/ / /_/ / `/ \/ / / / _/_// / / / / /_ / /_/ / / / / /> < / /_/ / / / / /_/ / / / /_/ / / / / / \ /_/ /_/_/_/ _ \,_/_/ /_/\,_/ \ /_/ \ //_/ /_/ Lecture 10:
More informationOracle Field Service/Laptop
Oracle Field Service/Laptop Concepts and Procedures Release 11i October 2001 Part No. A95212_01 1 Understanding Field Service/Laptop This topic group provides overviews of Field Service/Laptop and its
More informationInheritance and Interfaces
Inheritance and Interfaces Object Orientated Programming in Java Benjamin Kenwright Outline Review What is Inheritance? Why we need Inheritance? Syntax, Formatting,.. What is an Interface? Today s Practical
More informationComputer Science II. OO Programming Classes Scott C Johnson Rochester Institute of Technology
Computer Science II OO Programming Classes Scott C Johnson Rochester Institute of Technology Outline Object-Oriented (OO) Programming Review Initial Implementation Constructors Other Standard Behaviors
More informationOOPs Concepts. 1. Data Hiding 2. Encapsulation 3. Abstraction 4. Is-A Relationship 5. Method Signature 6. Polymorphism 7. Constructors 8.
OOPs Concepts 1. Data Hiding 2. Encapsulation 3. Abstraction 4. Is-A Relationship 5. Method Signature 6. Polymorphism 7. Constructors 8. Type Casting Let us discuss them in detail: 1. Data Hiding: Every
More informationInheritance STL. Entity Component Systems. Scene Graphs. Event Systems
Inheritance STL Entity Component Systems Scene Graphs Event Systems Event Systems Motivation: Decoupling events from where they are sent and where they are processed. It facilitates communication between
More informationBINARY SEARCH TREES CS 200 RECITATION 7
BINARY SEARCH TREES CS 200 RECITATION 7 Binary Search Tree (BST) Are binary trees (every node has at most two child nodes) For any given node, left sub-tree is less than it s value, and right sub-tree
More informationCOMP 250 Winter 2011 Reading: Java background January 5, 2011
Almost all of you have taken COMP 202 or equivalent, so I am assuming that you are familiar with the basic techniques and definitions of Java covered in that course. Those of you who have not taken a COMP
More informationLab 4. Out: Friday, February 25th, 2005
CS034 Intro to Systems Programming Doeppner & Van Hentenryck Lab 4 Out: Friday, February 25th, 2005 What you ll learn. In this lab, you ll learn to use function pointers in a variety of applications. You
More informationMedia Computation. Lecture 16.1, December 8, 2008 Steve Harrison
Media Computation Lecture 16.1, December 8, 2008 Steve Harrison Today -- Details of Creating Classes From requirements to classes Creating a class that will simulate a number game Practice going from requirements
More informationCS Programming I: Inheritance
CS 200 - Programming I: Inheritance Marc Renault Department of Computer Sciences University of Wisconsin Madison Fall 2017 TopHat Sec 3 (PM) Join Code: 719946 TopHat Sec 4 (AM) Join Code: 891624 Inheritance
More informationGoogle Drive: Access and organize your files
Google Drive: Access and organize your files Use Google Drive to store and access your files, folders, and Google Docs anywhere. Change a file on the web, your computer, or your mobile device, and it updates
More informationCS2102: Lecture on Abstract Classes and Inheritance. Kathi Fisler
CS2102: Lecture on Abstract Classes and Inheritance Kathi Fisler How to Use These Slides These slides walk you through how to share common code (i.e., create helper methods) across classes I recommend
More informationPolymorphism 2/12/2018. Which statement is correct about overriding private methods in the super class?
Which statement is correct about overriding private methods in the super class? Peer Instruction Polymorphism Please select the single correct answer. A. Any derived class can override private methods
More informationJava classes cannot extend multiple superclasses (unlike Python) but classes can implement multiple interfaces.
CSM 61B Abstract Classes & Interfaces Spring 2017 Week 5: February 13, 2017 1 An Appealing Appetizer 1.1 public interface Consumable { public void consume (); public abstract class Food implements Consumable
More informationTutorial 2 Today we will have a quick introduction to ArgoUML and how to use it, as well as look at some examples of class diagrams.
Tutorial 2 Today we will have a quick introduction to ArgoUML and how to use it, as well as look at some examples of class diagrams. This is an answer sheet, answers are marked in RED. Quiz dates: Quiz
More informationTopic 5 Polymorphism. " Inheritance is new code that reuses old code. Polymorphism is old code that reuses new code.
Topic 5 Polymorphism " Inheritance is new code that reuses old code. Polymorphism is old code that reuses new code. 1 Polymorphism Another feature of OOP literally having many forms object variables in
More informationComputer Science 2 Lecture 4 Inheritance: Trinidad Fruit Stand 02/15/2014 Revision : 1.7
Computer Science 2 Lecture 4 Inheritance: Trinidad Fruit Stand 02/15/2014 Revision : 1.7 1 Problem Ralph owns the Trinidad Fruit Stand that sells its fruit on the street, and he wants to use a computer
More informationpublic Twix() { calories = 285; ingredients = "chocolate, sugar, cookie, caramel"; }
Additional inheritance example As another example of inheritance, perhaps we would like to build an application about candy. For starters, let s say we want to do something with Twix bars and something
More informationOperator overloading
1 Introduction 2 The copy constructor 3 Operator Overloading 4 Eg 1: Adding two vectors 5 The -> operator 6 The this pointer 7 Overloading = 8 Unary operators 9 Overloading for the matrix class 10 The
More informationCONSTRUCTOR & Description. String() This initializes a newly created String object so that it represents an empty character sequence.
Constructor in Java 1. What are CONSTRUCTORs? Constructor in java is a special type of method that is used to initialize the object. Java constructor is invoked at the time of object creation. It constructs
More informationInheritance -- Introduction
Inheritance -- Introduction Another fundamental object-oriented technique is called inheritance, which, when used correctly, supports reuse and enhances software designs Chapter 8 focuses on: the concept
More informationCarleton University COMP1406/1006, Summer 2013 Tutorial 2
Carleton University COMP1406/1006, Summer 2013 Tutorial 2 Tuesday July 16 and Thursday July 18 When you have completed this tutorial, you should 1. Be comfortable with basic inheritance and overriding
More informationLesson 10B Class Design. By John B. Owen All rights reserved 2011, revised 2014
Lesson 10B Class Design By John B. Owen All rights reserved 2011, revised 2014 Table of Contents Objectives Encapsulation Inheritance and Composition is a vs has a Polymorphism Information Hiding Public
More informationITI Introduction to Computing II
ITI 1121. Introduction to Computing II Marcel Turcotte School of Electrical Engineering and Computer Science Inheritance Introduction Generalization/specialization Version of January 20, 2014 Abstract
More informationCSE115 Lab 2 Fall 2016
DUE DATES: Monday recitations: 9:00 PM on 9/25 Wednesday recitations: 9:00 PM on 9/27 Thursday recitations: 9:00 PM on 9/28 Friday recitations: 9:00 PM on 9/29 Saturday recitations: 9:00 PM on 9/30 Ready!
More informationCS445 Week 9: Lecture
CS445 Week 9: Lecture Objectives: To discuss the solution of the midterm and answer any doubts about grading issues. Also, during the discussion, refresh the topics from the first part of the course. Reading
More informationWeek 11: Class Design
Week 11: Class Design 1 Most classes are meant to be used more than once This means that you have to think about what will be helpful for future programmers There are a number of trade-offs to consider
More informationINHERITANCE AND EXTENDING CLASSES
INHERITANCE AND EXTENDING CLASSES Java programmers often take advantage of a feature of object-oriented programming called inheritance, which allows programmers to make one class an extension of another
More informationInheritance & Polymorphism
Inheritance & Polymorphism Procedural vs. object oriented Designing for Inheritance Test your Design Inheritance syntax **Practical ** Polymorphism Overloading methods Our First Example There will be shapes
More informationPart VIII. More classes. Philip Blakely (LSC) C++ Introduction 226 / 370
Part VIII More classes Philip Blakely (LSC) C++ Introduction 226 / 370 Inheritance Outline 29 Inheritance 30 Virtual functions 31 Polymorphism 32 Classes and static Philip Blakely (LSC) C++ Introduction
More informationECE 122. Engineering Problem Solving with Java
ECE 122 Engineering Problem Solving with Java Lecture 17 Inheritance Overview Problem: Can we create bigger classes from smaller ones without having to repeat information? Subclasses: a class inherits
More informationData Structures (list, dictionary, tuples, sets, strings)
Data Structures (list, dictionary, tuples, sets, strings) Lists are enclosed in brackets: l = [1, 2, "a"] (access by index, is mutable sequence) Tuples are enclosed in parentheses: t = (1, 2, "a") (access
More informationUML & OO Fundamentals. CSCI 4448/5448: Object-Oriented Analysis & Design Lecture 3 09/04/2012
UML & OO Fundamentals CSCI 4448/5448: Object-Oriented Analysis & Design Lecture 3 09/04/2012 1 Goals of the Lecture Review the material in Chapter 2 of the Textbook Cover key parts of the UML notation
More informationCS Week 15 Page 1
Reading: 1. Deitel & Deitel, Chapters 10 Objectives: 1. Continue discussing Object Oriented Programming 2. Final Exam Review Concepts: 1. More About Polymorphism References: 1. http://www.prenhall.com/deitel/
More informationCS1004: Intro to CS in Java, Spring 2005
CS1004: Intro to CS in Java, Spring 2005 Lecture #23: OO Design, cont d. Janak J Parekh janak@cs.columbia.edu Administrivia HW#5 due Tuesday And if you re cheating on (or letting others see your) HW#5
More informationGeneric BST Interface
Generic BST Interface Here s a partial generic BST interface: public class BST
More informationJava Basics. Object Orientated Programming in Java. Benjamin Kenwright
Java Basics Object Orientated Programming in Java Benjamin Kenwright Outline Essential Java Concepts Syntax, Grammar, Formatting, Introduce Object-Orientated Concepts Encapsulation, Abstract Data, OO Languages,
More informationTopic 10. Abstract Classes. I prefer Agassiz in the abstract, rather than in the concrete.
Topic 10 Abstract Classes I prefer Agassiz in the abstract, rather than in the concrete. 1 Back to the Property Example There are properties on a monopoly board Railroads, Utilities, and Streets are kinds
More informationChapter 10 Classes Continued. Fundamentals of Java
Chapter 10 Classes Continued Objectives Know when it is appropriate to include class (static) variables and methods in a class. Understand the role of Java interfaces in a software system and define an
More informationCSE 113. Announcements
CSE 113 September 20, 2010 Lab 3 posted Announcements Grades for all labs are still not being computed because of problem with Web-CAT s grading module hopefully we will get to a resolution this week Exam
More informationTips from the experts: How to waste a lot of time on this assignment
Com S 227 Spring 2018 Assignment 1 80 points Due Date: Friday, February 2, 11:59 pm (midnight) Late deadline (25% penalty): Monday, February 5, 11:59 pm General information This assignment is to be done
More informationITI Introduction to Computing II
ITI 1121. Introduction to Computing II Marcel Turcotte School of Electrical Engineering and Computer Science Inheritance Introduction Generalization/specialization Version of January 21, 2013 Abstract
More informationStarting to Program in C++ (Basics & I/O)
Copyright by Bruce A. Draper. 2017, All Rights Reserved. Starting to Program in C++ (Basics & I/O) On Tuesday of this week, we started learning C++ by example. We gave you both the Complex class code and
More informationCS1004: Intro to CS in Java, Spring 2005
CS1004: Intro to CS in Java, Spring 2005 Lecture #13: Java OO cont d. Janak J Parekh janak@cs.columbia.edu Administrivia Homework due next week Problem #2 revisited Constructors, revisited Remember: a
More informationInheritance and Polymorphism in Java
Inheritance and Polymorphism in Java Introduction In this article from my free Java 8 course, I will be discussing inheritance in Java. Similar to interfaces, inheritance allows a programmer to handle
More informationData Structures and Algorithms Dr. Naveen Garg Department of Computer Science and Engineering Indian Institute of Technology, Delhi.
Data Structures and Algorithms Dr. Naveen Garg Department of Computer Science and Engineering Indian Institute of Technology, Delhi Lecture 18 Tries Today we are going to be talking about another data
More informationLecture 14: more class, C++ streams
CIS 330: / / / / (_) / / / / _/_/ / / / / / \/ / /_/ / `/ \/ / / / _/_// / / / / /_ / /_/ / / / / /> < / /_/ / / / / /_/ / / / /_/ / / / / / \ /_/ /_/_/_/ _ \,_/_/ /_/\,_/ \ /_/ \ //_/ /_/ Lecture 14:
More informationCSCI-142 Exam 1 Review September 25, 2016 Presented by the RIT Computer Science Community
CSCI-12 Exam 1 Review September 25, 2016 Presented by the RIT Computer Science Community http://csc.cs.rit.edu 1. Provide a detailed explanation of what the following code does: 1 public boolean checkstring
More informationUML & OO FUNDAMENTALS CSCI 4448/5448: OBJECT-ORIENTED ANALYSIS & DESIGN LECTURE 3 08/30/2011
UML & OO FUNDAMENTALS CSCI 4448/5448: OBJECT-ORIENTED ANALYSIS & DESIGN LECTURE 3 08/30/2011 1 Goals of the Lecture Review the material in Chapter 2 of the Textbook Cover key parts of the UML notation
More informationSorting. Sorting. Selection sort
Sorting 1 Sorting Given a linear list of comparable objects of the same class (or values of the same type), we wish to sort (or reärrange) the objects in the increasing order. For simplicity, let s just
More informationDerived Classes in C++
Derived Classes in C++ Professor Hugh C. Lauer CS-2303, System Programming Concepts (Slides include materials from The C Programming Language, 2 nd edition, by Kernighan and Ritchie, Absolute C++, by Walter
More informationCOSC 121: Computer Programming II. Dr. Bowen Hui University of Bri?sh Columbia Okanagan
COSC 121: Computer Programming II Dr. Bowen Hui University of Bri?sh Columbia Okanagan 1 A1 Posted over the weekend Two ques?ons (s?ll long ques?ons) Review of main concepts from COSC 111 Prac?ce coding
More informationCS 200 More Classes Jim Williams, PhD
CS 200 More Classes Jim Williams, PhD Week 13 1. Team Lab: Instantiable Class 2. BP2 Milestone 3 Due Thursday 3. P7 Due next Thursday 4. CS 300 Programming II in the future? 5. Lecture: More Classes, UML
More informationProcedural Abstraction
Procedural Abstraction Comp-303 : Programming Techniques Lecture 5 Alexandre Denault Computer Science McGill University Winter 2004 February 16, 2004 Lecture 5 Comp 303 : Programming Techniques Page 1
More informationCS61BL Summer 2013 Midterm 2
CS61BL Summer 2013 Midterm 2 Sample Solutions + Common Mistakes Question 0: Each of the following cost you.5 on this problem: you earned some credit on a problem and did not put your five digit on the
More information