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

📄 percent.java

📁 老外的在线考试
💻 JAVA
字号:
/* * Core - Library of useful classes that are used in many CyberDemia projects. * Copyright (C) 2003 CyberDemia Research and Services * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU * Library General Public License for more details. *  * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA  02111-1307, USA. * * See the COPYING file located in the top-level-directory of * the archive of this library for complete text of license. */package com.cyberdemia.value;import com.cyberdemia.util.Format;/*** <p>* Percent encapsulates a percentage value.* This can be treated as a simple Javabean,* with a double property named <i>value</i>.* </p>* <p>* Note: A value of 1.0 represents 100%, 0.5 represents 50%,* 20 represents 2000%, and so on.* </p>* <p>* The formatting to a String is locale dependent,* hence this class depends on <code>com.cyberdemia.util.Format</code>* to perform formatting and manage locale.* </p>** @author  Alexander Yap* @see com.cyberdemia.util.Format* @version $Revision: 1.2 $ at $Date: 2004/02/18 08:35:30 $ by $Author: alexycyap $*/public class Percent extends DoubleType{	/**	* Default constructor	*/	public Percent()	{		super();	}	/**	* Convenient constructor.	*/	public Percent( double val)	{		super(val);	}	/**	* <p>	* Gets value as a String, using current locale as	* set in <code>com.cyberdemia.util.Format</code>, and	* default settings of 2 optional decimal points with groupings.	* </p>	* <p><b>Note:</b>The <code>toString()</code> method calls this method.	* </p>	*	* @return Percent string for the current locale.	* @see com.cyberdemia.util.Format#formatPercent( double, int, int, boolean )	*/	public String getStringValue()	{		return Format.formatPercent( getValue(), 0, 2, true );	}	/**	* Converts to a String, using current locale as set in	* <code>com.cyberdemia.util.Format</code>.	* The number of fractional digits can be specified.	* Grouping can be enabled or disabled.	*	* @param    minFracDigits  minimum number of fractional digits	* @param    maxFracDigits  maximum number of fractional digits	* @param    grouped        enable or disable grouping	* @return Percent string for the current locale.	* @see com.cyberdemia.util.Format#formatPercent( double, int, int, boolean )	*/	public String toString(int minFracDigits, int maxFracDigits, boolean grouped)	{		return Format.formatPercent( getValue(), minFracDigits, maxFracDigits, grouped);	}	/**	* Multiplies specified value with this percent.	* @param val  Value to apply percent to.	*/	public double doApply( double val )	{		return getValue()*val;	}	/**	* Creates a clone of this Percent object.	* @return  Clone of this object.	*/	public Object clone()	{		return new Percent( getValue() );	}}

⌨️ 快捷键说明

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