📄 noyes.java
字号:
/*====================================================================*\NoYes.javaNo-Yes option enumeration.------------------------------------------------------------------------This file is part of FuncPlotter, a combined Java application and appletfor plotting explicit functions in one variable.Copyright 2005-2007 Andy Morgan-Richards.FuncPlotter is free software: you can redistribute it and/or modify itunder the terms of the GNU General Public License as published by theFree Software Foundation, either version 3 of the License, or (at youroption) any later version.This program is distributed in the hope that it will be useful, butWITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNUGeneral Public License for more details.You should have received a copy of the GNU General Public License alongwith this program. If not, see <http://www.gnu.org/licenses/>.\*====================================================================*/// PACKAGEpackage util;//----------------------------------------------------------------------// NO-YES OPTION ENUMERATIONpublic enum NoYes{////////////////////////////////////////////////////////////////////////// Constants//////////////////////////////////////////////////////////////////////// NO ( "no", "false", "No" ), YES ( "yes", "true", "Yes" );////////////////////////////////////////////////////////////////////////// Constructors//////////////////////////////////////////////////////////////////////// private NoYes( String key1, String key2, String text ) { this.key1 = key1; this.key2 = key2; this.text = text; } //------------------------------------------------------------------////////////////////////////////////////////////////////////////////////// Class methods//////////////////////////////////////////////////////////////////////// public static NoYes get( String key ) { for ( NoYes value : values( ) ) { if ( value.key1.equals( key ) || value.key2.equals( key ) ) return value; } return null; } //------------------------------------------------------------------ public static NoYes get( boolean value ) { return ( value ? YES : NO ); } //------------------------------------------------------------------ public static String getKey( boolean value ) { return get( value ).getKey( ); } //------------------------------------------------------------------ public static String toString( boolean value ) { return get( value ).toString( ); } //------------------------------------------------------------------////////////////////////////////////////////////////////////////////////// Instance methods : overriding methods//////////////////////////////////////////////////////////////////////// public String toString( ) { return text; } //------------------------------------------------------------------////////////////////////////////////////////////////////////////////////// Instance methods//////////////////////////////////////////////////////////////////////// public String getKey( ) { return key1; } //------------------------------------------------------------------ public boolean toBoolean( ) { return ( (this == NO) ? false : true ); } //------------------------------------------------------------------////////////////////////////////////////////////////////////////////////// Instance variables//////////////////////////////////////////////////////////////////////// private String key1; private String key2; private String text;}//----------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -