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

📄 pswcell.java.svn-base

📁 java写的一个模拟cpu程序
💻 SVN-BASE
字号:
/**
 * PSWCell.java
 * 
 * 
 * @author 詹道楠
 * @date 2008-5-6
 */

package execute;

public class PSWCell extends Cell implements Parameters {
	
	private int state = 0;
	
	public static void main(String[] args) {

		PSWCell psw =  new PSWCell("0110");
		System.out.println(psw);
		psw.setState("1111111111111111111111101110");
		System.out.println(psw);

	}

	public PSWCell() {
		
		super(PSW);
		state = 0;
		
	}

	public PSWCell(String s) {
		
		super(PSW);
		state = (Integer.valueOf(s, 2));
		
	}

	public PSWCell(int state) {
		
		super(PSW);
		this.state = state;
		
	}

	/**
	 * Return the state.
	 */
	
	public int getState() {
	
		return state;
	
	}

	/**
	 * Return the state.
	 */
	
	public int getState(int i) {
	
		return state & i;
	
	}

	/**
	 * Clear the state.
	 */
	
	public void clearState(int i) {
	
		state = state & i;
		state = state & MASK;
	
	}

	/**
	 * Reset the state.
	 */
	
	public void setState(int i) {
	
		state = state | i;
		state = state & MASK;
	
	}

	/**
	 * Reset the state.
	 */
	
	public void setState(String s) {

		state = Integer.valueOf(s, 2) & MASK;
	
	}

	public String toString() {
		
		String stateString = Integer.toBinaryString(state);
		int i = 16 - stateString.length();
		
		if(i > 0) {
			StringBuffer sb = new StringBuffer(i);
			while(i > 0) {
				sb.append('0');
				--i;
			}
			return sb.toString() + stateString;
		}
		else
			return stateString;
	}

}

⌨️ 快捷键说明

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