package ga050426;

class OLEntries{
	int location;
	byte opcode;
	short address;
	OLEntries prev = null, next = null;
	
	OLEntries(int loc, byte opc, short add, OLEntries pre, OLEntries nex ){
		location = loc;
		opcode = opc;
		address = add;
		prev=pre;
		next=nex;
	}
	OLEntries(){this(0,(byte)0,(short)0,null,null);}
	public String toString(){
		StringBuffer buf = new StringBuffer();
		buf.append(String.format(" %s\t%s\t%s", location,
				opcode, address));
		return new String(buf);		
	}
}


public class ObjectLines {
		public static ObjectLines instance = new ObjectLines();
		OLEntries head = null ,tail = null, cur=null;

		public void enter(int location, byte opcode, short address){ 		
			if (tail != null)
				tail = tail.next = new OLEntries(location, opcode, address, tail, null);
			else
				cur = tail = head = new OLEntries(location, opcode, address, tail, null);
		}
		
		public OLEntries getNextEntrie(){
			OLEntries temp=cur;
			if(cur==null)return null;
			cur=cur.next;
			return temp;
		}
		
		private ObjectLines(){
		}
		
		
		
		public String toString() {
			StringBuffer buf = new StringBuffer(String.format("ObjectSourceLines%n"));
			for (OLEntries cur = head; cur != null; cur = cur.next) {
					buf.append(String.format(" %x\t%x\t%x%n", cur.location,
							cur.opcode, cur.address));
			}
			return new String(buf);
		}
}