CS106A, Stanford University

Slides:



Advertisements
Similar presentations
Written by: Dr. JJ Shepherd
Advertisements

Topic 5a – Interfaces Friends share all things. CISC370/Object Oriented Programming with Java.
ECE122 L16: Class Relationships April 3, 2007 ECE 122 Engineering Problem Solving with Java Lecture 16 Class Relationships.
OOP Project Develop an Application which incorporates the following OO Mechanisms and Principals: – Classes Visibility Constructor(s) Class Variable (if.
UML Class Diagram: class Rectangle
Abstraction: Polymorphism, pt. 1 Abstracting Objects.
16-Aug-15 Air Force Institute of Technology Electrical and Computer Engineering Object-Oriented Programming in Java Topic : Interfaces, Copying/Cloning,
Recitation 4 Abstract classes, Interfaces. A Little More Geometry! Abstract Classes Shape x ____ y ____ Triangle area() base____ height ____ Circle area()
Java Objects and Classes. Overview n Creating objects that belong to the classes in the standard Java library n Creating your own classes.
Chapter 14 Abstract Classes and Interfaces. Abstract Classes An abstract class extracts common features and functionality of a family of objects An abstract.
Abstract Classes and Interfaces Chapter 9 CSCI 1302.
MIT AITI 2004 – Lecture 13 Abstract Classes and Interfaces.
Programming Abstractions Cynthia Lee CS106X. Inheritance Topics Inheritance  The basics › Example: Stanford GObject class  Polymorphism › Example: Expression.
Chapter 3 Introduction to Classes and Objects Definitions Examples.
Lesson 6 – Libraries & APIs Libraries & APIs. Objective: We will explore how to take advantage of the huge number of pre-made classes provided with Java.
Chapter 3 Objects and Classes. Objects Object – a data type with structure, state, and operations to access and manipulate state - an instance of a class.
Bank Account Example public class BankAccount { private double balance; public static int totalAccounts = 0; public BankAccount() { balance = 0; totalAccounts++;
Topic 7 Interfaces I once attended a Java user group meeting where James Gosling (one of Java's creators) was the featured speaker. During the memorable.
CS 5JA Introduction to Java Pop Quiz Define/Explain encapsulation. In object-oriented programming, encapsulation refers to the grouping of data and the.
Quick Review of OOP Constructs Classes:  Data types for structured data and behavior  fields and methods Objects:  Variables whose data type is a class.
Written by: Dr. JJ Shepherd
Data Types Always data types will decide which type of information we are storing into variables In C programming language we are having 3 types of basic.
Object Oriented Programming in Java Habib Rostami Lecture 7.
1 C++ Classes & Object Oriented Programming Overview & Terminology.
Java Generics. Lecture Objectives To understand the objective of generic programming To be able to implement generic classes and methods To know the limitations.
浙江省. 浙江省位于中国 东南沿海东濒东海 ,南界福建,西与 江西、安徽相连, 北与上海,江苏为 邻。境内最大的河 流钱塘江,因江流 曲折,又称浙江, 省以江名,简称为 浙。
“ 东方明珠 ”── 香港和澳门 东北师大附中 王 瑶. 这是哪个城市的夜景? 香港 这是哪个城市的夜景? 澳门.
April 13, 1998CS102-02Lecture 3-1 Data Types in Java CS Lecture 3-1 Java’s Central Casting.
Graphing.
Written by: Dr. JJ Shepherd
Java Generics.
Web Design & Development Lecture 9
Review.
Inheritance and Polymorphism
Interface.
Agenda Warmup AP Exam Review: Litvin A2
Interfaces I once attended a Java user group meeting where James Gosling (Java's inventor) was the featured speaker. During the memorable Q&A session,
CS106A, Stanford University
Packages, Interfaces & Exception Handling
UML Class Diagram: class Rectangle
Templates.
CS 106A, Lecture 12 More Graphics
Topic 7 Interfaces I once attended a Java user group meeting where James Gosling (one of Java's creators) was the featured speaker. During the memorable.
CS106A, Stanford University
CS 106A, Lecture 14 Events and Instance Variables
CS 106A, Lecture 22 More Classes
CS106A, Stanford University
Inheritance Basics Programming with Inheritance
More inheritance, Abstract Classes and Interfaces
Interface.
Stack Memory 2 (also called Call Stack)
The Boolean (logical) data type boolean
Physics-based simulation for visual computing applications
CS106A, Stanford University
Advanced Java Programming
CS106A, Stanford University
Java Lesson 36 Mr. Kalmes.
Static in Classes CSCE 121 J. Michael Moore.
CS106A, Stanford University
CS106A, Stanford University
Java Inheritance.
Static is one of the modifiers that determine variable and method characteristics. The static modifier associates a variable or method with its class.
CS106A, Stanford University
CS106A, Stanford University
Review of Previous Lesson
C++ Programming CLASS This pointer Static Class Friend Class
Subtype Substitution Principle
Topics to cover Instance variables vs. local variables.
Presentation transcript:

CS106A, Stanford University Data Visualization Chris Piech CS106A, Stanford University

Be able to create a variable type from scratch Learning Goals Be able to create a variable type from scratch

A class defines a new variable type

You must define three things 1. What variables does each instance store? 2. What methods can you call on an instance? 3. What happens when you make a new one? *details on how to define these three things coming soon

https://www.youtube.com/watch?v=jbkSRLYSojo

extends Make a class inherit all the instance variables and methods of another class

public class Simulator extends GraphicsProgram { // class definition }

public class GRect extends GObject { // class definition }

I promise that this class will define implements I promise that this class will define a few given methods

public class GRect extends GObject implements GFillable { // class definition }

implements Also a cheeky way to share constants between classes I promise that this class will define a few given methods

public class NameSurferDatabase implements NameSurferConstants { // class definition }

This method isn’t called on an instance. Integer.parseInt(“52”) Math.sqrt(16); static This method isn’t called on an instance.

public class BubbleMaker { public static GOval makeBubble(Country country, int year){ double gdp = country.getGdp(year); double life = country.getLifeExpectancy(year); double pop = country.getPop(year); return makeBubbleHelper(gdp, life, pop); }