how to write a program for " world cup " in java
hi guys ,,,
im new in this forum ,,, i came here cause i needed help with something
i was trying to improve my java ,, so i decided to write a program for the world cup " calculates the points and goals .... etc"
but i had a problem with ranking the teams ,, i used linked lists to list the teams ,,, so this is the method i wrote for sorting teams ,, plz if you could help ill be thankful
public void sort(){
Team T1=new Team();
Team T2=new Team();
Team T3=new Team();
Team T4=new Team();
int max1=0;
int max2=0;
int max3=0;
int max4=0;
points();// calculates the points depending on how many time the team won or drew
Node current=first;
while(current!=null){
int P=current.data.P;// data.P means the teams points ofcourse data is of type team
if(P>=max1){
current.data.rank=1;
T1=current.data;
max1=P;
}
if(P>=max2&&P<max1){
current.data.rank=2;
T2=current.data;
max2=P;
}
if(P>=max3&&P<max2){
current.data.rank=3;
T3=current.data;
max3=P;
}
if(P>=max4&&P<max3){
current.data.rank=4;
T4=current.data;
max4=P;
}
if(T1.P>current.data.P){
T4=T3;
T3=T2;
T2=T1;
T1=current.data;
max4=max3;max3=max2;max2=max1;max1=current.data.P;
}
if(T2.P>current.data.P&&T2.P<max1){
T4=T3;
T3=T2;
T2=current.data;
max4=max3;max3=max2;max2=current.data.P;
}
if(T3.P>current.data.P&&T2.P<max2){
T4=T3;
T3=current.data;
max4=max3;max3=current.data.P;
}
if(T4.P>current.data.P&&T4.P<max3){
T4=current.data;
max4=current.data.P;
}
current=current.next;
}// end while
this.Empty();// this method empties the linked list
InsertAtFront(T4);
InsertAtFront(T3);
InsertAtFront(T2);
InsertAtFront(T1);
}// end method
thanks in advance