首页 > 文档 > Object 对象
2017
07-19

Object 对象

Name

Object 对象

   

Examples

// Declare and construct two objects (h1, h2) from the class HLine

HLine h1 = new HLine(20, 2.0);

HLine h2 = new HLine(50, 2.5);

 

void setup()

{

size(200, 200);

frameRate(30);

}

 

void draw() {

background(204);

h1.update();

h2.update();

}

 

class HLine {

float ypos, speed;

HLine (float y, float s) {

ypos = y;

speed = s;

}

void update() {

ypos += speed;

if (ypos > width) {

ypos = 0;

}

line(0, ypos, width, ypos);

}

}

Description

描述

Objects are instances of classes. A class is a grouping of related methods (functions) and fields (variables and constants).

对象是类的实例。类是相关方法 (函数) 和字段 (变量和常量) 的分组。

Syntax

ClassName instanceName

Parameters

ClassName

the class from which to create the new object

 

要从中创建新对象的类

instanceName

the name for the new object

新对象的名称

   

Related

class



最后编辑:
作者:卡萨布兰卡
这个作者貌似有点懒,什么都没有留下。

留下一个回复

你的email不会被公开。