About Me

Teaching paradigm

Learn It => Master It => Apply It

知识不是力量,

只有能被我们支配利用的知识才是力量

OOPS

  • Stands for Object-Oriented Programming Style

  • The most used programming paradigm

  • Treat everything as object that can interact with each other

Class vs object

Class

  • A blueprint, a description, an idea that we use to create object
  • A class defines fields (a.k.a. attributes or properties) and behaviors (methods)

 

Object

  • We create object based on class
  • We can create multiple objects based on one class

CREATE AIRPLANE

Fields (a.k.a. attributes or properties):

  • Weight
  • Color
  • Airline
  • ...

 

Behaviors (a.k.a. methods):

  • Take off
  • Land
  • ...

 

DEFINE AIRPLANE class

public class Airplane {

    // Fields (a.k.a. attributes or properties)
    String color;
    String airline;
    
    // Constructor (instruction for instantiating an airplane object)
    public Airplane(String color, String airline) {
    	this.color = color;
        this.airline = airline;
    }
    
    // Behaviors (a.k.a. methods)
    public void takeOff() {
    	...
    }
    
    public void land() {
    	...
    }
}

INSTANTIATE AIRPLANE object

// Instantiate airplane objects based on Airplane class
Airplane myAirplane = new Airplane("blue", "China Southern Airline");
Airplane urAirplane = new Airplane("yellow", "American Airline");

// Use airplane behaviors (methods)
myAirplane.takeOff();
urAirplane.land();

LET'S try CREATEing human

Fields (a.k.a. attributes or properties)

 

Behaviors (a.k.a. methods)

in THE WILD (real world)

in THE WILD (VIRTUAL WORLD)

YALI Demo Class

By Zico Deng

YALI Demo Class

  • 110