🎨
CMMobileBook
  • CMoney Mobile Book
  • Git主題
    • Git 基本知識
    • Git 使用方法
    • Git Flow 開發方式
    • Commit Message 規則
    • GitLab + SSH key
    • 相關學習網站
    • 延伸 Bitbucket 操作
  • Scrum主題
    • Scrum 基本知識
  • 程式練習題
    • 前言
    • 物件導向練習
      • StopWatch
    • Foundation 程式練習
      • 合法回文-1 Valid Palindrome
      • Reformat Date
      • Day of the Year
      • Peak Index in a Mountain Array
      • Number of Days Between Two Dates
      • To lower case
      • Two Sum
      • Best Time to Buy and Sell Stock
      • Best Time to Buy and Sell Stock II
    • 條件邏輯練習
      • FizzBuzz
      • Single Number
      • Self Dividing Number
Powered by GitBook
On this page

Was this helpful?

  1. 程式練習題
  2. 物件導向練習

StopWatch

題目一

請設計一個名為StopWatch的類別。此類別包括:

  • 資料欄位有startTime與endTime,並且外部只能get,不能set。

  • 產生StopWatch時,建構式有製造時間manufacturingDate,以目前時間當作參數。

  • 名為start()的方法,用來將startTime重新設定為目前時間。

  • 名為stop()的方法,用來將endTime設定為目前時間。

  • 名為getElapsedTime()的方法,回傳碼表所經過,以毫秒為單位的時間。

產生100,000個隨機數計,並且做排序由小到大。利用StopWatch類別來計算所需的時間和製造時間,並顯示結果。

Previous物件導向練習NextFoundation 程式練習

Last updated 4 years ago

Was this helpful?