<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                ![](https://box.kancloud.cn/91ee20bc20b5e7b03af557b7ef28d25b_688x371.png) ![](https://box.kancloud.cn/c9bdbf06ee60e272a311a44500e9b211_799x408.png) ~~~ // 車 class Car { constructor(num) { this.num = num } } // 入口攝像頭 class Camera { shot(car) { return { num: car.num, inTime: Date.now() } } } // 出口顯示器 class Screen { show(car, inTime) { console.log('車牌號', car.num) console.log('停車時間', Date.now() - inTime) } } // 停車場 class Park { constructor(floors) { this.floors = floors || [] this.camera = new Camera() this.screen = new Screen() this.carList = {} } in(car) { // 獲取攝像頭的信息:號碼 時間 const info = this.camera.shot(car) // 停到某個車位 const i = parseInt(Math.random() * 100 % 100) const place = this.floors[0].places[i] place.in() info.place = place // 記錄信息 this.carList[car.num] = info } out(car) { // 獲取信息 const info = this.carList[car.num] const place = info.place place.out() // 顯示時間 this.screen.show(car, info.inTime) // 刪除信息存儲 delete this.carList[car.num] } emptyNum() { return this.floors.map(floor => { return `${floor.index} 層還有 ${floor.emptyPlaceNum()} 個車位` }).join('\n') } } // 層 class Floor { constructor(index, places) { this.index = index this.places = places || [] } emptyPlaceNum() { let num = 0 this.places.forEach(p => { if (p.empty) { num = num + 1 } }) return num } } // 車位 class Place { constructor() { this.empty = true } in() { this.empty = false } out() { this.empty = true } } // 測試代碼------------------------------ // 初始化停車場 const floors = [] for (let i = 0; i < 3; i++) { const places = [] for (let j = 0; j < 100; j++) { places[j] = new Place() } floors[i] = new Floor(i + 1, places) } const park = new Park(floors) // 初始化車輛 const car1 = new Car('A1') const car2 = new Car('A2') const car3 = new Car('A3') console.log('第一輛車進入') console.log(park.emptyNum()) park.in(car1) console.log('第二輛車進入') console.log(park.emptyNum()) park.in(car2) console.log('第一輛車離開') park.out(car1) console.log('第二輛車離開') park.out(car2) console.log('第三輛車進入') console.log(park.emptyNum()) park.in(car3) console.log('第三輛車離開') park.out(car3) ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看