실행이 이상해요.......ㅠ.ㅠ
늘솜
import java.io.*;
import java.util.*;
class QueueNode
{
public long QueueItem;
public QueueNode Link;
}
class QueueList
{
private QueueNode front;
private QueueNode rear;
public QueueList()
{
front = null;
rear = null;
}
public void insert(long item)
{
QueueNode newNode = new QueueNode();
newNode.QueueItem = item;
front = null;
if ( isEmpty() )
{
rear = newNode;
front = newNode;
}
else
{
front = newNode;
rear = newNode;
}
}
public boolean remove(long item[])
{
if (isEmpty())
{
System.out.println(queue is empty);
return false;
}
else
{
item[0] = front.QueueItem;
front = rear;
if (front == null)
rear = null;
return true;
}
}
public boolean peek(long item[])
{
if ( isEmpty() )
{
System.out.println(stack is empty);
return false;
}
else
{
item[0] = front.QueueItem;
return true;
}
}
public boolean isEmpty()
{
return(front == null);
}
}
class QueueUsingList
{
public static void main(String[] args) throws IOException
{
QueueList aQueue = new QueueList();
while (true)
{
System.out.println(--------------);
System.out.println(QueueUsingList);
System.out.println(--------------);
System.out.println(1. Insert);
System.out.println(2. Delete);
System.out.println(3. Display List);
System.out.println(4. End Program);
System.out.print(Enter the number of command );
int command = getInt();
int Value;
switch (command)
{
case 1:
System.out.print(Enter the nummber to insert in the list );
Value = getInt();
aQueue.insert( Value );
System.out.println();
break;
case 2:
System.out.print(Enter the number to delete from the List );
long removeItem[]= new long[1];
while(aQueue.remove(removeItem) )
{
System.out.print(removeItem[6] + );
}
System.out.println();
break;
case 3:
long peekItem[] = new long[i];
for( i = 0; i = 6; i++)
System.out.print(peekItem + );
System.out.println();
break;
case 4:
System.exit(0);
break;
default:
System.out.println(Invalid entry);
}
}
}
public static int getInt() throws IOException
{
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
String s = br.readLine();
return Integer.parseInt(s);
}
}
코드가 이렇게 있는데?있는데 실행해서 값 입력해준후 디스플레이 누르면 이상한 영어들이 출력이 되네요.......ㅠ.ㅠ
그리고 분명 6개만 입력해야 하는데 더 입력되구요.... 고수님들 도와주세요.....ㅠ.ㅠ
원본파일도 텍스트파일로 올립니다. 도와주세요. 리스트를 이용한 쿠 구현인데 안되요.....