SOURCE

console 命令行工具 X clear

                    
>
console
<!doctype html>
<html>

<head>
	<title>一夜暴富</title>
	<meta charset="utf-8" />
    <style type="text/css">
    button:hover{
        background:#000;
        color:#fff;
    }
    button:active{
        background:red;
        color:blue;
    }
    </style>
</head>

<body>
	<button onclick="getcomputer()">暴富</button>
    <button onclick="computer.start()">开机</button>
    <button onclick="computer.stop()">关机</button>
    <button onclick="computer.drive()">运行</button>
    <button onclick="computer.addhdd()">加硬盘</button>
	<script>
            var cpu = ['i7 10','i7 9','i7 8','i7 7','i5 10','i5 9','i5 8']
            var gpu = ['rtx2080ti','rtx2080','rtx2070','rtx2060','gtx1660ti']
            var make = ['dell','lenovo','hp','acer','asus','aoc','mechrevo']
            var hdd = [2048,1024,512,256]
            var computer = {
                cpu:'i7 10',
                gpu:'rtx2080ti',
                make:'dell',
                hdd:128,
                started:false,
                addhdd:function(){
                    if(!this.started){
                    count=parseInt(prompt())
                    this.hdd=this.hdd+count
                    console.log(this.hdd)
                }
                else{
                    console.log("请先关机")
                }
                },
                drive:function(){
                    if(this.started){
                        if(this.hdd>0){
                            alert("computer has been started")
                            this.hdd=this.hdd-32
                            console.log(this.hdd)
                        }
                        else{
                            alert("hdd hasn't")
                            console.log(this.hdd)
                        }
                    }
                    else{
                        console.log("电脑已关机")
                    }
                },
                start:function(){
                    this.started = true
                    console.log(true)
                },
                stop:function(){
                    this.started = false
                    console.log(false)
                },
                nature:function(){
                    for (var prop in computer){
                        console.log(prop+':'+computer[prop])
                }
            }
            }
            function getcomputer(){
            var rand1 = Math.floor(Math.random()*cpu.length)
            var rand2 = Math.floor(Math.random()*gpu.length)
            var rand3 = Math.floor(Math.random()*make.length)
            var rand4 = Math.floor(Math.random()*hdd.length)
            console.log("you get "+make[rand3]+" "+cpu[rand1]+" "+gpu[rand2]+" "+hdd[rand4]+"G "+"computer")
            }
	</script>
</body>

</html>