您所在的位置:QQ首页 > 动画频道 > 高级应用> 正文

Calculator类 模拟科学计算器函数
http://flash.QQ.com   2006年 08月 29日 11:15   闪吧  
1 2 3 4 页
public function Ave() { //求平均值

//Ave=(x1+x2+x3+...+xn)/xn

if (data != undefined) {

if (this.datam.Ave != undefined) {

this._value = this.datam.Ave.toString(this._system);

} else {

if (this.datam.Sum == undefined) {

this.getSum();

}

this.datam.Ave = this.datam.Sum/this.data.length;

this._value = this.datam.Ave.toString(this._system);

}

this.isnew = 1;

this.broadMessage("Ave");

}

}

public function Ave2() { //求均方值

//Ave2=Sum2/n

if (this.data != undefined) {

if (this.datam.Ave2 != undefined) {

this._value = this.datam.Ave2.toString(this._system);

} else {

if (this.datam.Sum2 == undefined) {

this.getSum2();

}

this.datam.Ave2 = this.datam.Sum2/this.data.length;

this._value = this.datam.Ave2.toString(this._system);

}

this.isnew = 1;

this.broadMessage("Ave2");

}

}

public function Sum() { //求数据和

//Sum=x1+x2+x3+...+xn

if (data != undefined) {

if (this.datam.Sum != undefined) {

this._value = this.datam.Sum.toString(this._system);

} else {

this.getSum();

this._value = this.datam.Sum.toString(this._system);

}

this.isnew = 1;

this.broadMessage("Sum");

}

}

public function Sum2() { //求数据平方和

//Sum2=x1*x1+x2*x2+x3*x3+...+xn*xn

if (data != undefined) {

if (this.datam.Sum2 != undefined) {

this._value = this.datam.Sum2.toString(this._system);

} else {

this.getSum2();

this._value = this.datam.Sum2.toString(this._system);

}

this.isnew = 1;

this.broadMessage("Sum2");

}

}

public function S() { //求总体参数为n的标准差

//S=Math.sqrt((Sum2-n*Ave*Ave)/n)

if (data != undefined) {

if (this.datam.S != undefined) {

this._value = this.datam.S.toString(this._system);

} else {

if (this.datam.Ave == undefined) {

//计算Ave

if (this.datam.Sum == undefined) {

this.getSum();

}

this.datam.Ave = this.datam.Sum/this.data.length;

}

//计算Sum2

if (datam.Sum2 == undefined) {

this.getSum2();

}

//计算S

this.datam.S = Math.sqrt((this.datam.Sum2-this.data.length*this.datam.Ave*this.datam.Ave)/this.data.length);

this._value = this.datam.S.toString(this._system);

}

this.isnew = 1;

this.broadMessage("S");

}

}

public function S2() { //求总体参数为n-1的标准差

//S=Math.sqrt((Sum2-n*Ave*Ave)/(n-1))

if (data != undefined) {

if (this.datam.S2 != undefined) {

this._value = this.datam.S2.toString(this._system);

} else {

if (this.datam.Ave == undefined) {

//计算Ave

if (this.datam.Sum == undefined) {

this.getSum();

}

this.datam.Ave = this.datam.Sum/this.data.length;

}

//计算Sum2

if (datam.Sum2 == undefined) {

this.getSum2();

}

//计算S

this.datam.S2 = Math.sqrt((this.datam.Sum2-this.data.length*this.datam.Ave*this.datam.Ave)/(this.data.length-1));

this._value = this.datam.S2.toString(this._system);

}

this.isnew = 1;

this.broadMessage("S2");

}

}

public function Data() { //添加数据

if (this.data != undefined) {

if (this._system == 10) {

this.data.push(Number(_value));

} else {

this.data.push(parseInt(_value, _system));

}

this.datam = {Ave:undefined, Ave2:undefined, Sum:undefined, Sum2:undefined, S:undefined, S2:undefined};

this.isnew = 1;

this.broadMessage("Data");

}

}

public function load(n:Number) { //将数据显示在显示框中

if (this.data != undefined) {

this._value = this.data[n].toString(this._system);

this.isnew = 1;

this.broadMessage("load");

}

}

public function clear(n:Number) {

//清除数据 if (this.data != undefined) {

if (n == undefined) {

this.data.splice(n, 1);

} else {

this.data = [];

}

this.isnew = 1;

this.broadMessage("clear");

}

}

public function get hasData():Boolean {

return (this.data == undefined);

}

public function get n():Number {

return this.data.length;

}

}

上一页
[1] [2] [3] [4] 页
免费订阅】【发表评论】【动画论坛】【  】【关闭
发表评论
 QQ号码:
 QQ密码:
 验证码: 匿名发表
* 请各位网友遵纪守法并注意语言文明。
*《互联网电子公告服务管理规定》
*《全国人大常委会关于维护互联网安全的规定》




关于腾讯 | About Tencent | 服务条款 | 广告服务 | 腾讯招聘 | 腾讯公益 | 客服中心 | 网站导航
Copyright © 1998 - 2008 Tencent Inc. All Rights Reserved
腾讯公司 版权所有