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

📄 difficultyenum.java

📁 老外的在线考试
💻 JAVA
字号:
/* * SchoolEJB - CyberDemia's library of EJBs for educational related services. * 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.school;import com.cyberdemia.generic.AbstractEnum;import java.util.*;/** *  * DifficultyEnum represents an enumerated type to  * indicate the difficulty level of a question. *  * @author Alexander Yap */public final class DifficultyEnum extends AbstractEnum{	// Name strings. Used for display in GUIs, output, etc	private static final String TRIVIAL_NAME = "Trivial";	private static final String EASY_NAME = "Easy";	private static final String INTERMEDIATE_NAME = "Intermediate";	private static final String HARD_NAME = "Hard";	private static final String EXTREME_NAME = "Extreme";	// Enum strings. This is the same as the programatic name.	private static final String TRIVIAL_STR = "TRIVIAL";	private static final String EASY_STR = "EASY";	private static final String INTERMEDIATE_STR = "INTERMEDIATE";	private static final String HARD_STR = "HARD";	private static final String EXTREME_STR = "EXTREME";	// Enums	public static final DifficultyEnum TRIVIAL = new DifficultyEnum(new Integer(1),TRIVIAL_STR,TRIVIAL_NAME);	public static final DifficultyEnum EASY = new DifficultyEnum(new Integer(2),EASY_STR,EASY_NAME);	public static final DifficultyEnum INTERMEDIATE = new DifficultyEnum(new Integer(3),INTERMEDIATE_STR,INTERMEDIATE_NAME);	public static final DifficultyEnum HARD = new DifficultyEnum(new Integer(4),HARD_STR,HARD_NAME);	public static final DifficultyEnum EXTREME = new DifficultyEnum(new Integer(5),EXTREME_STR,EXTREME_NAME);	// Map of enum string to Integer.	private static Map s_strToEnumMap = new HashMap();	// Map of Integer code to AbstractEnum instance.	private static Map s_codeToEnumMap = new HashMap();	static	{		s_strToEnumMap.put(TRIVIAL_STR,TRIVIAL);		s_codeToEnumMap.put(TRIVIAL.getCode(),TRIVIAL);		s_strToEnumMap.put(EASY_STR,EASY);		s_codeToEnumMap.put(EASY.getCode(),EASY);		s_strToEnumMap.put(INTERMEDIATE_STR,INTERMEDIATE);		s_codeToEnumMap.put(INTERMEDIATE.getCode(),INTERMEDIATE);		s_strToEnumMap.put(HARD_STR,HARD);		s_codeToEnumMap.put(HARD.getCode(),HARD);		s_strToEnumMap.put(EXTREME_STR,EXTREME);		s_codeToEnumMap.put(EXTREME.getCode(),EXTREME);	}	/**	* Returns enumerate from the string representation of the enumerate.	* @param enumStr  String to search for.	* @return Enumerate specified by the string if it exists, otherwise null.	*/	public static DifficultyEnum getEnumFromString(String enumStr)	{		if (!s_strToEnumMap.containsKey(enumStr))			return null;		return (DifficultyEnum)s_strToEnumMap.get(enumStr);	}	/**	* Returns enumerate that matches specified code.	* @param code  Code to search for.	* @return Enumerate specified by the code if it exists, otherwise null.	*/	public static DifficultyEnum getEnumFromCode(Integer code)	{		if (!s_codeToEnumMap.containsKey(code))			return null;		return (DifficultyEnum)s_codeToEnumMap.get(code);	}	/**	* Returns array of all defined DifficultyEnum objects, sorted by their codes in ascending order.	* This method creates a new array.	* @return Array of all defined enumerates.	*/	public static DifficultyEnum[] getEnums()	{		LinkedList enumList = new LinkedList( s_codeToEnumMap.values() );		Collections.sort( enumList );		DifficultyEnum[] enumArray = new DifficultyEnum[enumList.size()];		return (DifficultyEnum[])enumList.toArray(enumArray);	}	// ctor protected to prevent user instantiation	protected DifficultyEnum(Integer code, String str, String name)	{		super(code, str, name);	}	protected DifficultyEnum()  { super(); }  // Not used.}

⌨️ 快捷键说明

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