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

📄 numberdisplay.java

📁 现在在国外大学里最流行的java学习软件,同时还有大量的example,在名为project的文件里.安装好后用bluej打开peoject的例子,可以进行你想要的任何变化.同时可以了解大量的源码
💻 JAVA
字号:
/** * The NumberDisplay class represents a digital number display that can hold * values from zero to a given limit. The limit can be specified when creating * the display. The values range from zero (inclusive) to limit-1. If used, * for example, for the seconds on a digital clock, the limit would be 60,  * resulting in display values from 0 to 59. When incremented, the display  * automatically rolls over to zero when reaching the limit. *  * @author Michael Kolling and David J. Barnes * @version 2006.03.30 */public class NumberDisplay{    private int limit;    private int value;    /**     * Constructor for objects of class NumberDisplay.     * Set the limit at which the display rolls over.     */    public NumberDisplay(int rollOverLimit)    {        limit = rollOverLimit;        value = 0;    }    /**     * Return the current value.     */    public int getValue()    {        return value;    }    /**     * Return the display value (that is, the current value as a two-digit     * String. If the value is less than ten, it will be padded with a leading     * zero).     */    public String getDisplayValue()    {        if(value < 10) {            return "0" + value;        }        else {            return "" + value;        }    }    /**     * Set the value of the display to the new specified value. If the new     * value is less than zero or over the limit, do nothing.     */    public void setValue(int replacementValue)    {        if((replacementValue >= 0) && (replacementValue < limit)) {            value = replacementValue;        }    }    /**     * Increment the display value by one, rolling over to zero if the     * limit is reached.     */    public void increment()    {        value = (value + 1) % limit;    }}

⌨️ 快捷键说明

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