Here's my compare to method:
public int compareTo(Object o)
{
// 1: films duration is greater than 'o'
if(this.duration > ((Film)o).duration)
return 1;
// 0: films duration equals 'o'
else if(this.duration == ((Film)o).duration)
return 0;
// -1: films durations is less than 'o'
return -1;
}
And my "enqueue" method for joining the queue which is unfinished:
public void enqueue (Comparable o)
{
if(isEmpty())
{
int temp =rear;
rear= (rear + 1) % queue.length;
if (front ==rear)
{
rear = temp;
throw new FullQueueException ();
}
queue[rear] = o;
}
else
{
for(int i = 0; i <= queue.length; i++)
{
//duration is greater so everything must be moved right
if(o.compareTo(queue[i]) == 1 )
{
for(int x = 0; x <= queue.length; x++)
{
int temp =rear;
rear= (rear + 1) % queue.length;
if (front ==rear)
{
rear = temp;
throw new FullQueueException ();
}
queue[rear] = queue[rear+1];
}
queue[front] = o;
}
if(o.compareTo(queue[i]) == 0 )
{
}
Just wondering if i'm on the right track or if what i'm doing is way off. Sorry for such a long post, thanks.. any help appreciated

New Topic/Question
Reply
MultiQuote










|