aspose file tools*
The moose likes Beginning Java and the fly likes can someone have a look Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "can someone have a look" Watch "can someone have a look" New topic
Author

can someone have a look

Chris Lavery
Ranch Hand

Joined: Nov 30, 2004
Posts: 54
hi everybody, ive done some coding for one of the tasks in my assignment but i cant really check it out fully until later on, so i was wondering if someone could tell me if it looks to meet the criteria it needs to.
Thanks in advance
Chris

2)You'll then need a class, say TopicManager, which maintains a list of most-recently updated TopicInfos; one of the fields of this class will be the list of current topics.

public class TopicManager
{
private static final int MAX_ITEMS = 100;
private ItemList items = null;
private int noItems = 0;


public TopicInfo update(int tid)
{

if (items == null) return null;


if (items.head().getID() == tid)
{
return items.head();
}

ItemList til = items;
TopicInfo ti;

while (til != null)
{
ti = til.head();
if (ti.getID() == tid)
{
til.pop();
items = new ItemList(ti,items);
return ti;
}
// ilPrev = il;
til = til.next();
}
return null;
}


public void addNew(TopicInfo ti)
{
if (noItems == 0)
{
items = new ItemList(ti);
}
else
{
items = new ItemList(ti,items);
}
if (noItems == MAX_ITEMS)
{
items.removeLast();
}
else
{
noItems++;
}
}


public TopicInfo[] getTopics()
{
TopicInfo[] tis = new TopicInfo[noItems];
ItemList il = items;

int i = 0;
while (i < noItems)
{
tis[i] = il.head();

il = il.next();
i++;
}
return tis;
}


public boolean isIn(int ID)
{
boolean found = false;
ItemList til = items;

while ((! found) && til != null)

{
found = (til.head().getID() == ID);
til = til.next();
}
return found;
}


}
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
No code review, just some advice:
1. Google: test-driven development
2. Google: unit test
3. Visit www.junit.org


There is no emoticon for what I am feeling!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: can someone have a look