对象丰田雷凌

<script>
    window.onload = function (ev) {
        var vcar=new Car("丰田","雷凌",55,1.8)

        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+25;
            document.write("<br>"+"加速:"+speed)
        }
        this.swerve= function () {
            var speed = currentSpeed-35;
            document.write("<br>"+"转向:"+speed);
        }
        this.stop = function () {
           var speed = 0;
           document.write("<br>"+"刹车:"+speed)
        }
        this.Turnofftheengine = function () {
            var speed = currentSpeed-45;
            document.write("<br>"+"关引擎:"+speed)
        }
    }
</script>

  

 

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