speedsetting.java

来自「Java mulitplayer strategy game. Adaptati」· Java 代码 · 共 70 行

JAVA
70
字号
/*
 * SpeedSetting.java
 *
 * Created on 1 listopad 2005, 13:01
 *
 * To change this template, choose Tools | Options and locate the template under
 * the Source Creation and Management node. Right-click the template and choose
 * Open. You can then make changes to the template in the Source Editor.
 */

package net.sf.jawp.api.domain;

import java.io.Serializable;

/**
 *
 * @author jarek
 */
public enum SpeedSetting implements Serializable
{
	
	
	ULTRA_SLOW( 0.001f, "ultra.slow"),
	VERY_SLOW( 0.025f, "very.slow"),
	SLOW( 0.05f, "slow"),
	SLOWER( 0.1f, "slower"),
	NORMAL( 0.25f, "normal"),
	FASTER(0.5f, "faster"),
	FAST( 1f, "fast"),
	VERY_FAST( 1f, "very.fast"),
	ULTRA_FAST( 5f, "ultra.fast");
	
	private static final long serialVersionUID = 1L;
	
	private final float value;
	
	private final String label;
	
	SpeedSetting( final float v, final String l )
	{
		this.value = v;
		this.label = l;
	}
	
	public final float getValue()
	{
		return this.value;
	}
	
	public final String getLabel()
	{
		return this.label;
	}
	
	public static int getPosition( final SpeedSetting setting)
	{
		final SpeedSetting[] vals = SpeedSetting.values();
		for ( int i = 0; i < vals.length; ++i)
		{
			if ( setting.equals(vals[i]))
			{
				return i;
			}
		}
		throw new IllegalArgumentException("unknown setting");
	}
	
	
}

⌨️ 快捷键说明

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