1.类和对象
1.1类定义
格式:public class 类名
{
成员数据
成员函数
}
}
}
}
}
2.继承与派生
2.1派生类:继承了基类的全部非私有成员,使用extends关键字表示此类是某类的派生类.
格式:
public class 派生类名 extends 基类名
{
派生类的成员数据
派生类的成员函数
}
}
}
2.2 派生类的构造函数:
派生类从基类继承了所有非私有成员,但是在建立派生类对象的时候系统只执行派生类的构造函数,而不会自动执行基类的构造函数,调用基类构造函数使用super函数.
}
}
}
4.接口:包含一组虚方法的抽象类型,其中每一种方法都有其名称,参数和返回值.
一个类可以实现多个接口.
格式: package 接口所在的包
{
public interface 接口名
{
}
}
package Test
{
public interface ICommand
{
function execute(event:CairngormEvent):void //定义接口方法
}
}
{
public interface ICommand
{
function execute(event:CairngormEvent):void //定义接口方法
}
}
5.使用类实现接口
格式:public class 类名 implements 接口1,接口2....
{
接口中的方法;
}
}
}
}