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

📄 virtualequipment.java

📁 OS设备管理课程设计源代码 模拟操作体统功能
💻 JAVA
字号:
package equipment;
public class VirtualEquipment {
	private char equipmentName;
	private boolean freeFlag;
	private int workTime;
	public VirtualEquipment(char name){
		equipmentName=name;
		freeFlag=false;//设备空闲
	}
	public char getEquipmentName(){
		return equipmentName;
	}
	public boolean isFree(){
		return !freeFlag;
	}
	public void setFree(){
		freeFlag=false;
	}
	public void applyEquipment(int time)throws EquipmentBusyException{
		if(!isFree())
			throw new EquipmentBusyException();
		freeFlag=true;
		workTime=time;
	}
	public void timeDecrease()throws EquipmentHasBeenFree{
		workTime--;
		if(workTime==0){
			freeFlag=false;
			throw new EquipmentHasBeenFree();
		}
	}
	public class EquipmentHasBeenFree extends Exception{
		private static final long serialVersionUID = 1L;
		public EquipmentHasBeenFree(){}
		public String toString(){
			return "设备已经空闲";
		}
	}
	public class EquipmentBusyException extends Exception{
		private static final long serialVersionUID = 1L;
		public EquipmentBusyException(){};
		public String toString(){
			return "设备正忙!";
		}
	}
}

⌨️ 快捷键说明

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