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

📄 queueclass.java

📁 java小程序
💻 JAVA
字号:
class QueueClass implements QueueInterface
{
private int head;
private int tail;
private Man queue[];
public QueueClass()
{
head=tail=0;
queue= new Man[4];
}
public boolean isEmpty()
{
return (head==tail)?true:false;
}
public void addTail(String name)
{
if((tail)%queue.length==head)
System.out.printf("队列满了"+name+"无法加入");
else queue[(tail++)%queue.length]=new Man(name);
}
public Man removeHead()
{
if(isEmpty())
{
System.out.printf("队列空白");
return new Man(" ");
}
head=(head+1)%queue.length;
return queue[head];
}
public void show()
{
int p=head;
System.out.print("显示队列");
while(p!=tail)
{
p=(p+1)%queue.length;
System.out.print(queue[p].getName()+" ");
}
System.out.println();
}
}


⌨️ 快捷键说明

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