Quick Review of Object-Oriented Programming in Go

Size: px
Start display at page:

Download "Quick Review of Object-Oriented Programming in Go"

Transcription

1 Quick Review of Object-Oriented Programming in Go

2 Structs: Grouping Variables as Objects type Rectangle struct { x1 float64 y1 float64 width float64 height float64 type Circle struct { x1 float64 y1 float64 radius float64

3 Area Functions for Shapes? func Area(R Rectangle) float64 { return R.width * R.length func Area(C Circle) float64 { return math.pi * C.radius * C.radius

4 Area Functions for Shapes? func Area(R Rectangle) float64 { return R.width * R.length func Area(C Circle) float64 { return math.pi * C.radius * C.radius Error! Can t name two functions the same thing.

5 Workaround: Methods func (R Rectangle) Area() float64 { return R.width*R.length func (C Circle) Area() float64 { return R.radius * R.radius * math.pi Call these methods with R.Area() and C.Area() same setup that we used for accessing fields.

6 Pointers Help Us Change Fields Inside Method We couldn t access fields inside a method... func (C Circle) DoubleRadius() { C.radius = 2*C.radius Solution: Take a pointer to a Circle as the input. func (C *Circle) DoubleRadius() { C.radius = 2*C.radius // note double-meaning of *

7 Inheritance and Polymorphism

8 Rectangle Fields/Methods type Rectangle struct { x1,y1 float64 width, height float64 fillcolor color.color strokecolor color.color linewidth int Natural to create an object type for each shape: Circle Oval Triangle Star Square. These methods are needed for all shapes. func (r *Rectangle) Area() float64 func (r *Rectangle) MoveTo(x,y int) func (r *Rectangle) Resize(w,h int) func (r *Rectangle) Draw(d *DrawingCanvas) func (r *Rectangle) SetLineWidth(w int) func (r *Rectangle) ContainsPoint(x,y int)

9 Circle Fields/Methods type Circle struct { x0,y0 int radius int fillcolor color.color strokecolor color.color linewidth int Natural to create an object type for each shape: Circle Oval Triangle Star Square. These methods are needed for all shapes. func (c *Circle) Area() float64 func (c *Circle) MoveTo(x,y int) func (c *Circle) Resize(w,h int) func (c *Circle) Draw(d *DrawingCanvas) func (c *Circle) SetLineWidth(w int) func (c *Circle) ContainsPoint(x,y int)

10 Applying Canvas Methods to All Shapes type ShapeCanvas struct { width, height int backgroundcolor color.color shapes []???? But what type should go here???! func (c *ShapeCanvas) ShapeArea() float64{ sum := 0.0 for shape := range c.shapes { sum += shape.area() return sum

11 Solution: Interfaces type ShapeCanvas struct { width, height int backgroundcolor color.color shapes []Shape type Shape interface { Area() float64 MoveTo(x,y int) Resize(w,h int) Draw(c *DrawingCanvas) SetLineWidth(w int) The interface contains the methods shared by its types.

12 Solution: Interfaces type ShapeCanvas struct { width, height int backgroundcolor color.color shapes []Shape func (c *ShapeCanvas) ShapeArea() float64{ sum := 0.0 for shape := range c.shapes { sum += shape.area() return sum Note: We don t have to say that Circle/Square are Shapes!

13 interface{ As a Universal Type We also can use interface{ as a universal type. func main() float64{ var x interface{ // x can take any type! x = 3 fmt.println(x) x = AGT // no error here! fmt.println(x) Note: This is not a reason to ignore types.

14 interface{ As a Universal Type

15 Information-Hiding in Go When we examine the details of fmt.print(), we see 1300 lines of ugly, complicated functions.

16 Information-Hiding in Go When we examine the details of fmt.print(), we see 1300 lines of ugly, complicated functions. But do we need to know any of this in order to print an int?

17 Information-Hiding in Go When we call fmt.println( Hello world! )... this function calls within the fmt package fmt.fprintln(os.stdout, Hello world! )... which in turn calls p := newprinter() p.doprintf( Hello world!, true, true)...

18 Information-Hiding in Go which is very complicated... func (p *pp) doprint(a []interface{, addspace, addnewline bool) { prevstring := false for argnum := 0; argnum < len(a); argnum++ { p.fmt.clearflags() // always add spaces if we're doing Println arg := a[argnum] if argnum > 0 { isstring := arg!= nil && reflect.typeof(arg).kind() == reflect.string if addspace!isstring &&!prevstring { p.buf.writebyte(' ') prevstring = p.printarg(arg, 'v', 0) if addnewline { p.buf.writebyte('\n')

19 Information-Hiding in Go Not only do we not need to know exactly what this does... p := fmt.newprinter() p.doprintf( Hello world!, true, true)... but this gives us a compile error! // undefined: fmt.newprinter Think: Why would Go not allow us to access this function?

20 Public/Private Functions in Go 1. Public: accessible outside of the package (with import packagename ). Begin with upper case letter. 2. Private: accessible only to other functions within the package; can never be accessed with import packagename ). Begin with lower case letter. func UPGMA(mtx [][]float64) *Tree // can be accessed from outside package (public) func averagedist(mtx [][]float64, clusters []Cluster, i,j,k int) float64 // helper function for UPGMA (private)

21 Has vs. Is A struct has certain properties. A circle has a radius A Contact has a first name A Flight has a duration But how can we represent is? A circle is a shape A Contact is a person A City is a node in a network

22 Ordering Shapes Hierarchically Shapes Ellipses Triangles Stars Quadrilaterals Circles Equilateral Isosceles Parallelogram Rhombus Rectangle Square

23 Ordering Vehicles in a Video Game?

24 Previously: Interfaces type ShapeCanvas struct { width, height int backgroundcolor color.color shapes []Shape type Shape interface { Area() float64 MoveTo(x,y int) Resize(w,h int) Draw(c *DrawingCanvas) SetLineWidth(w int) But interfaces only allow objects to share methods...

25 One Possible Field-Sharing Solution type Automobile struct { width, height float64 topspeed float64 numoftires int type Car struct { auto Automobile numberofdoors int type Ferrari struct { car Car // other stuff that makes a Ferrari func main() { vroom := new(ferrrari) vroom.ctopspeed = // error!

26 One Possible Field-Sharing Solution type Automobile struct { width, height float64 topspeed float64 numoftires int type Car struct { auto Automobile numberofdoors int type Ferrari struct { car Car // other stuff that makes a Ferrari func main() { vroom := new(ferrrari) vroom.car.auto.topspeed = // ugly!

27 Better Idea: Anonymous Fields type Automobile struct { width, height float64 topspeed float64 numoftires int type Car struct { Automobile //a Car is an Automobile numberofdoors int type Ferrari struct { Car //a Ferrari is a Car // other stuff that makes a Ferrari func main() { vroom := new(ferrrari) vroom.topspeed = // this works!

28 Better Idea: Anonymous Fields Furthermore, a Ferrari can be used in place of a Car or Automobile anywhere we like in functions. func (a *Automobile) Start() { // It would probably be more natural to use interfaces for most functions, though each car will drive differently. func main() { vroom := new(ferrari) vroom.start() // this works!

29 Another Example of Anonymous Fields type Parallelogram struct { x1, y1 float64 width, height float64 theta float64 type Rectangle struct { Parallelogram //anonymous field func (p *Parallelogram) Area() float64 { return p.width * p.height func main() { r := new(rectangle) r.width, r.height = 3.0, 5.0 //OK! fmt.println(r.area()) //OK! Prints 15

30 ! Four Defining Principles of OOP Abstraction! Encapsulation! Object-! Oriented! Programming! Inheritance!! Polymorphism!

31 Abstraction If it walks like a circle, swims like a circle, and quacks like a circle...

32 Abstraction An abstraction denotes the essential characteristics of an object that distinguish it from all other kinds of object and thus provide crisply defined conceptual boundaries, relative to the perspective of the viewer. Courtesy: Gary Booch!

33 Abstraction The main example of abstraction in Go is with structs and methods. type Rectangle struct { x1,y1 float64 width, height float64 fillcolor color.color strokecolor color.color linewidth int func (r *Rectangle) Area() float64 func (r *Rectangle) MoveTo(x,y int) func (r *Rectangle) Resize(w,h int) func (r *Rectangle) Draw(d *DrawingCanvas) func (r *Rectangle) SetLineWidth(w int) func (r *Rectangle) ContainsPoint(x,y int)

34 Encapsulation Encapsulation: group together related things, and hide as many details as possible from the user. Examples in Go: Functions: to use fmt.printf() we only need to know what it takes and what it returns. Packages: Inside the fmt package is 1279 lines of code, but we only need to know public functions. Interfaces: I have a Shape, but I don t need to know what kind of shape in order to resize it.

35 Say something about HW6 Here

36 Note about HW6 This is why we are anal about the function requirements in HW6 In practice, the boss won t care about how you implement something. They just want the product to have certain properties.

37 Inheritance Inheritance: the ability for one class of objects to inherit the properties of another class. type Automobile struct { width, height float64 topspeed float64 numoftires int type Car struct { Automobile //a Car is an Automobile numberofdoors int type Ferrari struct { Car //a Ferrari is a Car // other stuff that makes a Ferrari

38 Polymorphism Polymorphism: the ability to have the same interface for presenting different objects. type Shape interface { Area() float64 MoveTo(x,y int) Resize(w,h int) func (C *Circle) Area() float64 { return math.pi * C.radius * C.radius func (R *Rectangle) Area() float64 { return R.width * R.length

39 Polymorphism This may seem heavily related to inheritance, so let me give a better example. x := Hello y := World! a := 3 b := 4 fmt.println(a+b, x+y) Strings and ints are unrelated, but Go can interpret the + symbol in different ways for both types.

Last Time: Objects and Abstraction. If it walks like a circle, swims like a circle, and quacks like a circle...!

Last Time: Objects and Abstraction. If it walks like a circle, swims like a circle, and quacks like a circle...! Pointers 02-201 Last Time: Objects and Abstraction If it walks like a circle, swims like a circle, and quacks like a circle...! Bird s Eye View of Object-Oriented Programming http://null-byte.wonderhowto.com!

More information

Lecture Overview Methods and Interfaces Methods review Interfaces Example: using the sort interface Anonymous fields in structs

Lecture Overview Methods and Interfaces Methods review Interfaces Example: using the sort interface Anonymous fields in structs 1 Lecture Overview Methods and Interfaces Methods review Interfaces Example: using the sort interface Anonymous fields in structs Generic printing using the empty interface Maps Creating a map Accessing

More information

Module 10 Inheritance, Virtual Functions, and Polymorphism

Module 10 Inheritance, Virtual Functions, and Polymorphism Module 10 Inheritance, Virtual Functions, and Polymorphism Table of Contents CRITICAL SKILL 10.1: Inheritance Fundamentals... 2 CRITICAL SKILL 10.2: Base Class Access Control... 7 CRITICAL SKILL 10.3:

More information

Object Oriented Programming in C#

Object Oriented Programming in C# Introduction to Object Oriented Programming in C# Class and Object 1 You will be able to: Objectives 1. Write a simple class definition in C#. 2. Control access to the methods and data in a class. 3. Create

More information

Introduzione a Go e RPC in Go

Introduzione a Go e RPC in Go Università degli Studi di Roma Tor Vergata Dipartimento di Ingegneria Civile e Ingegneria Informatica Introduzione a Go e RPC in Go Corso di Sistemi Distribuiti e Cloud Computing A.A. 2017/18 Valeria Cardellini

More information

Java Class Design. Eugeny Berkunsky, Computer Science dept., National University of Shipbuilding

Java Class Design. Eugeny Berkunsky, Computer Science dept., National University of Shipbuilding Java Class Design Eugeny Berkunsky, Computer Science dept., National University of Shipbuilding eugeny.berkunsky@gmail.com http://www.berkut.mk.ua Objectives Implement encapsulation Implement inheritance

More information

Name: Class: Date: 2. I have four vertices. I have four right angles and all my sides are the same length.

Name: Class: Date: 2. I have four vertices. I have four right angles and all my sides are the same length. 1. Circle the right triangles. Use the corner of a piece of paper to check. 2. I have four vertices. I have four right angles and all my sides are the same length. What am I? 3. I have four vertices. All

More information

Programovací jazyky F# a OCaml. Chapter 3. Composing primitive types into data

Programovací jazyky F# a OCaml. Chapter 3. Composing primitive types into data Programovací jazyky F# a OCaml Chapter 3. Composing primitive types into data Data types» We can think of data type as a set: int = -2, -1, 0, 1, 2, More complicated with other types, but possible» Functions

More information

Object-Oriented Programming Concepts

Object-Oriented Programming Concepts Object-Oriented Programming Concepts Real world objects include things like your car, TV etc. These objects share two characteristics: they all have state and they all have behavior. Software objects are

More information

More C++ : Vectors, Classes, Inheritance, Templates

More C++ : Vectors, Classes, Inheritance, Templates Vectors More C++ : Vectors,, Inheritance, Templates vectors in C++ basically arrays with enhancements indexed similarly contiguous memory some changes defined differently can be resized without explicit

More information

More C++ : Vectors, Classes, Inheritance, Templates. with content from cplusplus.com, codeguru.com

More C++ : Vectors, Classes, Inheritance, Templates. with content from cplusplus.com, codeguru.com More C++ : Vectors, Classes, Inheritance, Templates with content from cplusplus.com, codeguru.com 2 Vectors vectors in C++ basically arrays with enhancements indexed similarly contiguous memory some changes

More information

Java Object Oriented Design. CSC207 Fall 2014

Java 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 information

ame Date Class Practice A 11. What is another name for a regular quadrilateral with four right angles?

ame Date Class Practice A 11. What is another name for a regular quadrilateral with four right angles? ame Date Class Practice A Polygons Name each polygon. 1. 2. 3. 4. 5. 6. Tell whether each polygon appears to be regular or not regular. 7. 8. 9. 10. What is another name for a regular triangle? 11. What

More information

What is a Programming Paradigm

What is a Programming Paradigm INTRODUCTION This chapter begins with brief discussion of various Programming paradigms that C++ supports i.e., procedural programming style, object based programming style and object oriented programming

More information

Erlang and Go (CS262a, Berkeley Fall 2016) Philipp Moritz

Erlang and Go (CS262a, Berkeley Fall 2016) Philipp Moritz Erlang and Go (CS262a, Berkeley Fall 2016) Philipp Moritz The Problem Distributed computation is hard! State Hard to do recovery, dependency on order of execution Concurrency and Synchronization Hard to

More information

Clean Classes. Christopher Simpkins Chris Simpkins (Georgia Tech) CS 2340 Objects and Design CS / 11

Clean Classes. Christopher Simpkins Chris Simpkins (Georgia Tech) CS 2340 Objects and Design CS / 11 Clean Classes Christopher Simpkins chris.simpkins@gatech.edu Chris Simpkins (Georgia Tech) CS 2340 Objects and Design CS 1331 1 / 11 Data Abstraction with Classes Consider a concrete Point data type: public

More information

Name: Date: Period: Lab: Inscribed Quadrilaterals

Name: Date: Period: Lab: Inscribed Quadrilaterals Name: Date: Period: Materials: ompass Straightedge Lab: Inscribed Quadrilaterals Part A: Below are different categories of quadrilaterals. Each category has 2-4 figures. Using a compass and straightedge,

More information

MENSURATION-I (Area & Perimeter) In this chapter, we shall be dealing with plane figures of various shapes finding their sides, perimeters and

MENSURATION-I (Area & Perimeter) In this chapter, we shall be dealing with plane figures of various shapes finding their sides, perimeters and INTRODUCTION In this chapter, we shall be dealing with plane figures of various shapes finding their sides, perimeters and areas. AREA The area of any figure is the amount of surface enclosed within its

More information

More About Classes CS 1025 Computer Science Fundamentals I Stephen M. Watt University of Western Ontario

More About Classes CS 1025 Computer Science Fundamentals I Stephen M. Watt University of Western Ontario More About Classes CS 1025 Computer Science Fundamentals I Stephen M. Watt University of Western Ontario The Story So Far... Classes as collections of fields and methods. Methods can access fields, and

More information

n HW5 out, due Tuesday October 30 th n Part 1: Questions on material we ll cover today n Part 2: BFS using your graph from HW4

n HW5 out, due Tuesday October 30 th n Part 1: Questions on material we ll cover today n Part 2: BFS using your graph from HW4 Subtype, Subtyping vs. Subclassing, Liskov Substitution Principle Announcements n HW5 out, due Tuesday October 30 th n Part 1: Questions on material we ll cover today n Part 2: BFS using your graph from

More information

Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecture - 43 Dynamic Binding (Polymorphism): Part III Welcome to Module

More information

Lines Plane A flat surface that has no thickness and extends forever.

Lines Plane A flat surface that has no thickness and extends forever. Lines Plane A flat surface that has no thickness and extends forever. Point an exact location Line a straight path that has no thickness and extends forever in opposite directions Ray Part of a line that

More information

Introduction to Computers and Java

Introduction to Computers and Java Introduction to Computers and Java Chapter 1 Chapter 1 1 Objectives overview computer hardware and software introduce program design and object-oriented programming overview the Java programming language

More information

Aim: How do we find the volume of a figure with a given base? Get Ready: The region R is bounded by the curves. y = x 2 + 1

Aim: How do we find the volume of a figure with a given base? Get Ready: The region R is bounded by the curves. y = x 2 + 1 Get Ready: The region R is bounded by the curves y = x 2 + 1 y = x + 3. a. Find the area of region R. b. The region R is revolved around the horizontal line y = 1. Find the volume of the solid formed.

More information

Polygons - Part 1. Triangles

Polygons - Part 1. Triangles Polygons - Part 1 Triangles Introduction Complementary Angles: are two angles that add up to 90 Example: degrees A ADB = 65 degrees Therefore B + ADB BDC 65 deg 25 deg D BDC = 25 degrees C 90 Degrees Introduction

More information

Java Primer. CITS2200 Data Structures and Algorithms. Topic 2

Java Primer. CITS2200 Data Structures and Algorithms. Topic 2 CITS2200 Data Structures and Algorithms Topic 2 Java Primer Review of Java basics Primitive vs Reference Types Classes and Objects Class Hierarchies Interfaces Exceptions Reading: Lambert and Osborne,

More information

GO IDIOMATIC CONVENTIONS EXPLAINED IN COLOR

GO IDIOMATIC CONVENTIONS EXPLAINED IN COLOR GO IDIOMATIC CONVENTIONS EXPLAINED IN COLOR REVISION 1 HAWTHORNE-PRESS.COM Go Idiomatic Conventions Explained in Color Published by Hawthorne-Press.com 916 Adele Street Houston, Texas 77009, USA 2013-2018

More information

CS 251 Intermediate Programming Methods and Classes

CS 251 Intermediate Programming Methods and Classes CS 251 Intermediate Programming Methods and Classes Brooke Chenoweth University of New Mexico Fall 2018 Methods An operation that can be performed on an object Has return type and parameters Method with

More information

CS 251 Intermediate Programming Methods and More

CS 251 Intermediate Programming Methods and More CS 251 Intermediate Programming Methods and More Brooke Chenoweth University of New Mexico Spring 2018 Methods An operation that can be performed on an object Has return type and parameters Method with

More information

CREATED BY: Muhammad Bilal Arslan Ahmad Shaad. JAVA Chapter No 5. Instructor: Muhammad Naveed

CREATED BY: Muhammad Bilal Arslan Ahmad Shaad. JAVA Chapter No 5. Instructor: Muhammad Naveed CREATED BY: Muhammad Bilal Arslan Ahmad Shaad JAVA Chapter No 5 Instructor: Muhammad Naveed Muhammad Bilal Arslan Ahmad Shaad Chapter No 5 Object Oriented Programming Q: Explain subclass and inheritance?

More information

Student Mathematician: Date: Some, All or None Tell whether each statement below is true or false by circling the correct answer. If the statement is false, give a counterexample using words and/or pictures.

More information

Object-oriented programming. and data-structures CS/ENGRD 2110 SUMMER 2018

Object-oriented programming. and data-structures CS/ENGRD 2110 SUMMER 2018 Object-oriented programming 1 and data-structures CS/ENGRD 2110 SUMMER 2018 Lecture 4: OO Principles - Polymorphism http://courses.cs.cornell.edu/cs2110/2018su Lecture 3 Recap 2 Good design principles.

More information

Programming in the Large II: Objects and Classes (Part 2)

Programming in the Large II: Objects and Classes (Part 2) Programming in the Large II: Objects and Classes (Part 2) 188230 Advanced Computer Programming Asst. Prof. Dr. Kanda Runapongsa Saikaew (krunapon@kku.ac.th) Department of Computer Engineering Khon Kaen

More information

OBJECT ORIENTED PROGRAMMING

OBJECT ORIENTED PROGRAMMING OBJECT ORIENTED PROGRAMMING OBJECT ORIENTED PROGRAMMING Design principles for organizing code into user-defined types Principles include: Encapsulation Inheritance Polymorphism http://en.wikipedia.org/wiki/encapsulation_(object-oriented_programming)

More information

Object Design Guidelines

Object Design Guidelines Object Design Guidelines 1 / 17 Design Smells Rigidity system is too hard to change becuase change in one place forces changes in many other places Fragility changes break things that are conceptually

More information

Java Basics. Object Orientated Programming in Java. Benjamin Kenwright

Java 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 information

Outline. Subtype Polymorphism, Subtyping vs. Subclassing, Liskov Substitution Principle. Benefits of Subtype Polymorphism. Subtype Polymorphism

Outline. Subtype Polymorphism, Subtyping vs. Subclassing, Liskov Substitution Principle. Benefits of Subtype Polymorphism. Subtype Polymorphism Subtype, Subtyping vs. Subclassing, Liskov Substitution Principle Outline Subtype polymorphism Subtyping vs. subclassing Liskov Substitution Principle (LSP) Function subtyping Java subtyping Composition:

More information

1. Software Systems Complexity, OO Paradigm, UML

1. Software Systems Complexity, OO Paradigm, UML 1. Software Systems Complexity, OO Paradigm, UML Software Systems Complexity Inherent Arbitrary Complexity Problem Domain Complexity Expressing the Requirements Changing Requirements System Evolution -

More information

Geometry Vocabulary. acute angle-an angle measuring less than 90 degrees

Geometry Vocabulary. acute angle-an angle measuring less than 90 degrees Geometry Vocabulary acute angle-an angle measuring less than 90 degrees angle-the turn or bend between two intersecting lines, line segments, rays, or planes angle bisector-an angle bisector is a ray that

More information

Math 6, Unit 8 Notes: Geometric Relationships

Math 6, Unit 8 Notes: Geometric Relationships Math 6, Unit 8 Notes: Geometric Relationships Points, Lines and Planes; Line Segments and Rays As we begin any new topic, we have to familiarize ourselves with the language and notation to be successful.

More information

An angle that has a measure less than a right angle.

An angle that has a measure less than a right angle. Unit 1 Study Strategies: Two-Dimensional Figures Lesson Vocab Word Definition Example Formed by two rays or line segments that have the same 1 Angle endpoint. The shared endpoint is called the vertex.

More information

OBJECT ORIENTED PROGRAMMING USING C++ CSCI Object Oriented Analysis and Design By Manali Torpe

OBJECT ORIENTED PROGRAMMING USING C++ CSCI Object Oriented Analysis and Design By Manali Torpe OBJECT ORIENTED PROGRAMMING USING C++ CSCI 5448- Object Oriented Analysis and Design By Manali Torpe Fundamentals of OOP Class Object Encapsulation Abstraction Inheritance Polymorphism Reusability C++

More information

8. prove that triangle is a scalene triangle, right triangle, and/or an isosceles triangle. (evaluation)

8. prove that triangle is a scalene triangle, right triangle, and/or an isosceles triangle. (evaluation) Subject: Geometry Unit: Analytic Geometry Grade: 10 Students will: 1. compare parallel and perpendicular slopes. (analysis) 2. find the slope of a line given two points. (application) 3. find the length

More information

Shapes. Reflection Symmetry. Exercise: Draw the lines of symmetry of the following shapes. Remember! J. Portelli

Shapes. Reflection Symmetry. Exercise: Draw the lines of symmetry of the following shapes. Remember! J. Portelli Reflection Symmetry Shapes Learning Intention: By the end of the lesson you will be able to Identify shapes having reflection and/or rotational symmetry. Exercise: Draw the lines of symmetry of the following

More information

CS-202 Introduction to Object Oriented Programming

CS-202 Introduction to Object Oriented Programming CS-202 Introduction to Object Oriented Programming California State University, Los Angeles Computer Science Department Lecture III Inheritance and Polymorphism Introduction to Inheritance Introduction

More information

ITI Introduction to Computing II

ITI 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 information

Last Time: Rolling a Weighted Die

Last Time: Rolling a Weighted Die Last Time: Rolling a Weighted Die import math/rand func DieRoll() int { return rand.intn(6) + 1 Multiple Rolls When we run this program 100 times, we get the same outcome! func main() int { fmt.println(dieroll())

More information

Practice Problems for Geometry from

Practice Problems for Geometry from 1 (T/F): A line has no endpoint. 2 In Figure 2, angle DAE measures x, and angle DEC measures y. What is the degree measure of angle EBC? 3 (T/F): A triangle can have exactly two 60 degree angles. 4 An

More information

OBJECT ORİENTATİON ENCAPSULATİON

OBJECT ORİENTATİON ENCAPSULATİON OBJECT ORİENTATİON Software development can be seen as a modeling activity. The first step in the software development is the modeling of the problem we are trying to solve and building the conceptual

More information

Introduction to Object-Oriented Programming

Introduction to Object-Oriented Programming Introduction to Object-Oriented Programming Objects and classes Abstract Data Types (ADT). Encapsulation OOP: Introduction 1 Pure Object-Oriented Languages Five rules [Source: Alan Kay]: Everything in

More information

Properties of Triangles

Properties of Triangles Starter 1) Solve 4sin(x) - 1 = 0 for 0 < x < 360 2) Properties of Triangles Today we are learning... The properties and types of triangles. I will know if I have been successful if... I can identify and

More information

Definition: Convex polygon A convex polygon is a polygon in which the measure of each interior angle is less than 180º.

Definition: Convex polygon A convex polygon is a polygon in which the measure of each interior angle is less than 180º. Definition: Convex polygon A convex polygon is a polygon in which the measure of each interior angle is less than 180º. Definition: Convex polygon A convex polygon is a polygon in which the measure of

More information

SENIOR HIGH MATH LEAGUE April 24, GROUP III Emphasis on GEOMETRY SECTION I: ONE POINT EACH

SENIOR HIGH MATH LEAGUE April 24, GROUP III Emphasis on GEOMETRY SECTION I: ONE POINT EACH SENIOR HIGH MATH LEAGUE TEST A Unless otherwise stated give exact answers. 1 Find the exact area in square inches of an equilateral triangle whose base is of length 10 inches. 2. Give the smallest possible

More information

Spiral Back: Evaluate the following when x = -2 and y = 3 1) -4y x + (3+ x 2 ) Solve the following equations: 2) x 6 = -20 3) 2x 2 = -16 4)

Spiral Back: Evaluate the following when x = -2 and y = 3 1) -4y x + (3+ x 2 ) Solve the following equations: 2) x 6 = -20 3) 2x 2 = -16 4) Name: Date: / / Spiral Back: Evaluate the following when x = -2 and y = 3 1) -4y x + (3+ x 2 ) Let s see what you remember! Sticker Challenge! Solve the following equations: 2) x 6 = -20 3) 2x 2 = -16

More information

Stanford CS193p. Developing Applications for ios. Spring CS193p. Spring 2016

Stanford CS193p. Developing Applications for ios. Spring CS193p. Spring 2016 Stanford Developing Applications for ios Today Views Custom Drawing Demo FaceView Views A view (i.e. UIView subclass) represents a rectangular area Defines a coordinate space For drawing And for handling

More information

OCaml Data CMSC 330: Organization of Programming Languages. User Defined Types. Variation: Shapes in Java

OCaml Data CMSC 330: Organization of Programming Languages. User Defined Types. Variation: Shapes in Java OCaml Data : Organization of Programming Languages OCaml 4 Data Types & Modules So far, we ve seen the following kinds of data Basic types (int, float, char, string) Lists Ø One kind of data structure

More information

ITI Introduction to Computing II

ITI 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 information

Structured Programming

Structured Programming CS 170 Java Programming 1 Objects and Variables A Little More History, Variables and Assignment, Objects, Classes, and Methods Structured Programming Ideas about how programs should be organized Functionally

More information

Geometry: Semester 2 Practice Final Unofficial Worked Out Solutions by Earl Whitney

Geometry: Semester 2 Practice Final Unofficial Worked Out Solutions by Earl Whitney Geometry: Semester 2 Practice Final Unofficial Worked Out Solutions by Earl Whitney 1. Wrapping a string around a trash can measures the circumference of the trash can. Assuming the trash can is circular,

More information

Object Oriented Programming 2015/16. Final Exam June 28, 2016

Object Oriented Programming 2015/16. Final Exam June 28, 2016 Object Oriented Programming 2015/16 Final Exam June 28, 2016 Directions (read carefully): CLEARLY print your name and ID on every page. The exam contains 8 pages divided into 4 parts. Make sure you have

More information

UNIT 6 Nets and Surface Area Overhead Slides

UNIT 6 Nets and Surface Area Overhead Slides UNIT 6 Nets and Surface Area Overhead Slides Overhead Slides 6.1 Polygons 6.2 Triangles 6.3 Quadrilaterals 6.4 Name that Shape! 6.5 Drawing Parallelograms 6.6 3-D Shapes 6.7 Cuboid 6.8 Prism 6.9 Plan and

More information

GM1.1 Consolidation Worksheet Answers

GM1.1 Consolidation Worksheet Answers Cambridge Essentials Mathematics Support 8 GM1.1 Consolidation Worksheet Answers GM1.1 Consolidation Worksheet Answers 1 a a = 60 Angles on a straight line add to 180. b b = 150 Angles on a straight line

More information

Inheritance. OOP components. Another Example. Is a Vs Has a. Virtual Destructor rule. Virtual Functions 4/13/2017

Inheritance. OOP components. Another Example. Is a Vs Has a. Virtual Destructor rule. Virtual Functions 4/13/2017 OOP components For : COP 3330. Object oriented Programming (Using C++) http://www.compgeom.com/~piyush/teach/3330 Data Abstraction Information Hiding, ADTs Encapsulation Type Extensibility Operator Overloading

More information

Expanding Our Horizons. CSCI 4448/5448: Object-Oriented Analysis & Design Lecture 9 09/25/2011

Expanding Our Horizons. CSCI 4448/5448: Object-Oriented Analysis & Design Lecture 9 09/25/2011 Expanding Our Horizons CSCI 4448/5448: Object-Oriented Analysis & Design Lecture 9 09/25/2011 1 Goals of the Lecture Cover the material in Chapter 8 of our textbook New perspective on objects and encapsulation

More information

Binghamton University. CS-211 Fall Object Orientation

Binghamton University. CS-211 Fall Object Orientation Object Orientation 1 View the World as Classes of Objects An object is the computer model of a real object In object oriented programming, we group the objects our program is concerned about into classes

More information

CC Geometry H Do Now: Complete the following: Quadrilaterals

CC Geometry H Do Now: Complete the following: Quadrilaterals im #26: What are the properties of parallelograms? Geometry H o Now: omplete the following: Quadrilaterals Kite iagonals are perpendicular One pair of opposite angles is congruent Two distinct pairs of

More information

Digits. Value The numbers a digit. Standard Form. Expanded Form. The symbols used to show numbers: 0,1,2,3,4,5,6,7,8,9

Digits. Value The numbers a digit. Standard Form. Expanded Form. The symbols used to show numbers: 0,1,2,3,4,5,6,7,8,9 Digits The symbols used to show numbers: 0,1,2,3,4,5,6,7,8,9 Value The numbers a digit represents, which is determined by the position of the digits Standard Form Expanded Form A common way of the writing

More information

Lesson 4.3 Ways of Proving that Quadrilaterals are Parallelograms

Lesson 4.3 Ways of Proving that Quadrilaterals are Parallelograms Lesson 4.3 Ways of Proving that Quadrilaterals are Parallelograms Getting Ready: How will you know whether or not a figure is a parallelogram? By definition, a quadrilateral is a parallelogram if it has

More information

Object-Oriented Programming for Scientific Computing

Object-Oriented Programming for Scientific Computing Object-Oriented Programming for Scientific Computing Templates and Static Polymorphism Ole Klein Interdisciplinary Center for Scientific Computing Heidelberg University ole.klein@iwr.uni-heidelberg.de

More information

MSO Lecture 1. Wouter Swierstra (adapted by HP) September 11, 2017

MSO Lecture 1. Wouter Swierstra (adapted by HP) September 11, 2017 1 MSO Lecture 1 Wouter Swierstra (adapted by HP) September 11, 2017 So you think you can program... 2 From nrc.nl 3 Question: why do ICT-projects fail so often? 4 5 Question: why do ICT-projects fail so

More information

Closed shapes with straight sides

Closed shapes with straight sides 41 Unit 6 and 7 Properties of 2D shapes Activity 1 Closed shapes with straight sides (polygons). Let s revise the 2D shapes you learnt about in Grade 5 Closed shapes with straight sides triangle quadrilateral

More information

Yimin Math Centre. 6.1 Properties of geometrical figures Recognising plane shapes... 1

Yimin Math Centre. 6.1 Properties of geometrical figures Recognising plane shapes... 1 Yimin Math Centre Student Name: Grade: Date: Score: Table of Contents 6 Year 7 Term 3 Week 6 Homework 1 6.1 Properties of geometrical figures............................ 1 6.1.1 Recognising plane shapes...........................

More information

Mensuration: Basic Concepts and Important Formulas

Mensuration: Basic Concepts and Important Formulas Equilateral Triangle: All the three sides are equal and each angle is equal to. Height (Altitude) = 3(side) Isosceles Triangle: Two sides and two angles are equal and altitude drawn on nonequal side bisects

More information

Tokens, Expressions and Control Structures

Tokens, Expressions and Control Structures 3 Tokens, Expressions and Control Structures Tokens Keywords Identifiers Data types User-defined types Derived types Symbolic constants Declaration of variables Initialization Reference variables Type

More information

5.1 Any Way You Slice It

5.1 Any Way You Slice It SECONDARY MATH III // MODULE 5 MODELING WITH GEOMETRY 5.1 Students in Mrs. Denton s class were given cubes made of clay and asked to slice off a corner of the cube with a piece of dental floss. Jumal sliced

More information

Lecture #1. Introduction to Classes and Objects

Lecture #1. Introduction to Classes and Objects Lecture #1 Introduction to Classes and Objects Topics 1. Abstract Data Types 2. Object-Oriented Programming 3. Introduction to Classes 4. Introduction to Objects 5. Defining Member Functions 6. Constructors

More information

Modern C++ for Computer Vision and Image Processing. Igor Bogoslavskyi

Modern C++ for Computer Vision and Image Processing. Igor Bogoslavskyi Modern C++ for Computer Vision and Image Processing Igor Bogoslavskyi Outline Move semantics Classes Operator overloading Making your class copyable Making your class movable Rule of all or nothing Inheritance

More information

+ Inheritance. Sometimes we need to create new more specialized types that are similar to types we have already created.

+ Inheritance. Sometimes we need to create new more specialized types that are similar to types we have already created. + Inheritance + Inheritance Classes that we design in Java can be used to model some concept in our program. For example: Pokemon a = new Pokemon(); Pokemon b = new Pokemon() Sometimes we need to create

More information

Computer Science & Information Technology (CS) Rank under AIR 100. Examination Oriented Theory, Practice Set Key concepts, Analysis & Summary

Computer Science & Information Technology (CS) Rank under AIR 100. Examination Oriented Theory, Practice Set Key concepts, Analysis & Summary GATE- 2016-17 Postal Correspondence 1 C-Programming Computer Science & Information Technology (CS) 20 Rank under AIR 100 Postal Correspondence Examination Oriented Theory, Practice Set Key concepts, Analysis

More information

Module 01 Processing Recap

Module 01 Processing Recap Module 01 Processing Recap Processing is a language a library an environment Variables A variable is a named value. It has a type (which can t change) and a current value (which can change). Variables

More information

ECE 3574: Dynamic Polymorphism using Inheritance

ECE 3574: Dynamic Polymorphism using Inheritance 1 ECE 3574: Dynamic Polymorphism using Inheritance Changwoo Min 2 Administrivia Survey on class will be out tonight or tomorrow night Please, let me share your idea to improve the class! 3 Meeting 10:

More information

Word Tutorial 4 Enhancing Page Layout and Design

Word Tutorial 4 Enhancing Page Layout and Design Word Tutorial 4 Enhancing Page Layout and Design Microsoft Office 2013 Objectives Use continuous section break for page layout Format text in columns Insert symbols and special characters Distinguish between

More information

(SSOL) Simple Shape Oriented Language

(SSOL) Simple Shape Oriented Language (SSOL) Simple Shape Oriented Language Madeleine Tipp Jeevan Farias Daniel Mesko mrt2148 jtf2126 dpm2153 Description: SSOL is a programming language that simplifies the process of drawing shapes to SVG

More information

Introduction to Design Patterns

Introduction to Design Patterns Introduction to Design Patterns First, what s a design pattern? a general reusable solution to a commonly occurring problem within a given context in software design It s not a finished design that can

More information

JAVA: A Primer. By: Amrita Rajagopal

JAVA: A Primer. By: Amrita Rajagopal JAVA: A Primer By: Amrita Rajagopal 1 Some facts about JAVA JAVA is an Object Oriented Programming language (OOP) Everything in Java is an object application-- a Java program that executes independently

More information

Conditionals & Loops /

Conditionals & Loops / Conditionals & Loops 02-201 / 02-601 Conditionals If Statement if statements let you execute statements conditionally. true "then" part condition a > b false "else" part func max(a int, b int) int { var

More information

Contents. Lines, angles and polygons: Parallel lines and angles. Triangles. Quadrilaterals. Angles in polygons. Congruence.

Contents. Lines, angles and polygons: Parallel lines and angles. Triangles. Quadrilaterals. Angles in polygons. Congruence. Colegio Herma. Maths Bilingual Departament Isabel Martos Martínez. 2015 Contents Lines, angles and polygons: Parallel lines and angles Triangles Quadrilaterals Angles in polygons Congruence Similarity

More information

Basic Object-Orientation

Basic Object-Orientation Basic Object-Orientation Chapters 2 and 4 / Hour 2 2002, Delroy A. Brinkerhoff Basic Object-Orientation Slide 1 of 21 Chapters 2 and 4 / Hour 2 # Objects and Classes # Abstraction and classification (generalization)

More information

Industrial Programming

Industrial Programming Industrial Programming Lecture 4: C# Objects & Classes Industrial Programming 1 What is an Object Central to the object-oriented programming paradigm is the notion of an object. Objects are the nouns a

More information

What is an Object. Industrial Programming. What is a Class (cont'd) What is a Class. Lecture 4: C# Objects & Classes

What is an Object. Industrial Programming. What is a Class (cont'd) What is a Class. Lecture 4: C# Objects & Classes What is an Object Industrial Programming Lecture 4: C# Objects & Classes Central to the object-oriented programming paradigm is the notion of an object. Objects are the nouns a person called John Objects

More information

Geometry. Geometry is the study of shapes and sizes. The next few pages will review some basic geometry facts. Enjoy the short lesson on geometry.

Geometry. Geometry is the study of shapes and sizes. The next few pages will review some basic geometry facts. Enjoy the short lesson on geometry. Geometry Introduction: We live in a world of shapes and figures. Objects around us have length, width and height. They also occupy space. On the job, many times people make decision about what they know

More information

index.pdf January 21,

index.pdf January 21, index.pdf January 21, 2013 1 ITI 1121. Introduction to Computing II Circle Let s complete the implementation of the class Circle. Marcel Turcotte School of Electrical Engineering and Computer Science Version

More information

3. Here is a stem and leaf plot of the Weights of students in East Junior High Algebra I Class

3. Here is a stem and leaf plot of the Weights of students in East Junior High Algebra I Class Test One Review Fall 06 Math 236 1. If a student budgets her money as indicated by this pie graph, how much of her weekly $170 goes to food? Expenses misc. 10% housing 20% housing 2. The following box

More information

Object Model. Object Orientated Analysis and Design. Benjamin Kenwright

Object Model. Object Orientated Analysis and Design. Benjamin Kenwright Object Model Object Orientated Analysis and Design Benjamin Kenwright Outline Submissions/Quizzes Review Object Orientated Programming Concepts (e.g., encapsulation, data abstraction,..) What do we mean

More information

5th Grade Geometry

5th Grade Geometry Slide 1 / 112 Slide 2 / 112 5th Grade Geometry 2015-11-23 www.njctl.org Slide 3 / 112 Geometry Unit Topics Click on the topic to go to that section Polygons Classifying Triangles & Quadrilaterals Coordinate

More information

Programming, numerics and optimization

Programming, numerics and optimization Programming, numerics and optimization Lecture A-4: Object-oriented programming Łukasz Jankowski ljank@ippt.pan.pl Institute of Fundamental Technological Research Room 4.32, Phone +22.8261281 ext. 428

More information

Triangle Geometry Isometric Triangles Lesson 1

Triangle Geometry Isometric Triangles Lesson 1 Triangle eometry Isometric Triangles Lesson 1 Review of all the TORMS in OMTRY that you know or soon will know!. Triangles 1. The sum of the measures of the interior angles of a triangle is 180º (Triangle

More information

Last class. -More on polymorphism -super -Introduction to interfaces

Last class. -More on polymorphism -super -Introduction to interfaces Last class -More on polymorphism -super -Introduction to interfaces Interfaces Sometimes in Java, we will have 2 classes that both share a similar structure, but neither of them is clearly the parent or

More information

Module 01 Processing Recap. CS 106 Winter 2018

Module 01 Processing Recap. CS 106 Winter 2018 Module 01 Processing Recap CS 106 Winter 2018 Processing is a language a library an environment Variables A variable is a named value. It has a type (which can t change) and a current value (which can

More information

New Perspectives on Microsoft Word Module 4: Enhancing Page Layout and Design

New Perspectives on Microsoft Word Module 4: Enhancing Page Layout and Design New Perspectives on Microsoft Word 2016 Module 4: Enhancing Page Layout and Design Objectives, Part 1 Use continuous section break for page layout Format text in columns Insert symbols and special characters

More information