⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 clockdisplay.java

📁 现在在国外大学里最流行的java学习软件,同时还有大量的example,在名为project的文件里.安装好后用bluej打开peoject的例子,可以进行你想要的任何变化.同时可以了解大量的源码
💻 JAVA
字号:
/** * The ClockDisplay class implements a digital clock display for a * European-style 24 hour clock. The clock shows hours and minutes. The  * range of the clock is 00:00 (midnight) to 23:59 (one minute before  * midnight). *  * The clock display receives "ticks" (via the timeTick method) every minute * and reacts by incrementing the display. This is done in the usual clock * fashion: the hour increments when the minutes roll over to zero. *  * @author Michael Kolling and David J. Barnes * @version 2006.03.30 */public class ClockDisplay{    private NumberDisplay hours;    private NumberDisplay minutes;    private String displayString;    // simulates the actual display        /**     * Constructor for ClockDisplay objects. This constructor      * creates a new clock set at 00:00.     */    public ClockDisplay()    {        hours = new NumberDisplay(24);        minutes = new NumberDisplay(60);        updateDisplay();    }    /**     * Constructor for ClockDisplay objects. This constructor     * creates a new clock set at the time specified by the      * parameters.     */    public ClockDisplay(int hour, int minute)    {        hours = new NumberDisplay(24);        minutes = new NumberDisplay(60);        setTime(hour, minute);    }    /**     * This method should get called once every minute - it makes     * the clock display go one minute forward.     */    public void timeTick()    {        minutes.increment();        if(minutes.getValue() == 0) {  // it just rolled over!            hours.increment();        }        updateDisplay();    }    /**     * Set the time of the display to the specified hour and     * minute.     */    public void setTime(int hour, int minute)    {        hours.setValue(hour);        minutes.setValue(minute);        updateDisplay();    }    /**     * Return the current time of this display in the format HH:MM.     */    public String getTime()    {        return displayString;    }        /**     * Update the internal string that represents the display.     */    private void updateDisplay()    {        displayString = hours.getDisplayValue() + ":" +                         minutes.getDisplayValue();    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -