public void log
(){
if(start==null)
System.out.println("List is empty..");
else{
Node temp=start;
System.out.print("->");
//get rid of each user with a similar method but with a random user removed....
while(temp.next!=start
)
{
int r = rand.nextInt(2) ;
if(r==0)
{
deleteAt(counter);
System.out.println("Is Logged Off "+temp.data);
}
else if(r==1)
{
System.out.println("Is Logged on "+temp.data);
}
counter++;
temp=temp.next;
}
}
}
public void deleteAt(int position){
Node current=start;
Node previous=start;
for(int i=0;i<position;i++){
if(current.next==start)
break;
previous=current;
current=current.next;
}
if(position==0)
deleteFirst();
else
previous.next=current.next;
count--;
}
public void deleteFirst() {
Node temp=start;
while(temp.next!=start){
temp=temp.next;
}
temp.next=start.next;
start=start.next;
count--;
}
public int size(){
return count;
}
michael.james.90475 -3 Newbie Poster
michael.james.90475 -3 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.