对象大众宝莱

<script>
    window.onload = function (ev) {

        var vcar = new Car("大众","宝莱",60,1.6);

        vcar.startup();
        vcar.Startengine();
        vcar.changeSpeed();
        vcar.swerve();
        vcar.stop();
        vcar.Turnofftheengine()
    }

    function Car(make, model, currentSpeed, displacement) {
        var currentSpeed = currentSpeed;

        this.startup = function () {
            document.write("启动:0");
        };
        this.Startengine = function () {
            var speed = currentSpeed;
            document.write("<br>" + "启动引擎:" + speed);
        };
        this.changeSpeed = function () {
            var speed = currentSpeed*3/2;
            document.write("<br>"+"加速:"+speed);
        }
        this.swerve = function () {
            var  speed = currentSpeed/3;
            document.write("<br>"+"转向:"+speed);
        }
        this.stop = function () {
            var speed = 0;
            document.write("<br>"+"刹车:"+speed)
        }
        this.Turnofftheengine = function () {
            var speed = currentSpeed/10;
            document.write("<br>"+"关引擎:"+speed)
        }
    }
</script>

  

 

posted @ 2018-04-12 10:06  麦克斯-侯  阅读(95)  评论(0编辑  收藏  举报
百纵科技