Help on Ranking
Hi, my name is Nicholas I'm current new to programming and I'm working on a scoring program so it can help my friend record the score with ease.
The link below is an example on how the scoring works.
http://img.photobucket.com/albums/v684/nictan/example.jpg
http://img.photobucket.com/albums/v684/nictan/example.jpg
My question to it is
how can you do a Ranking system?
How can you do a prioritizing as in if the best of 3 scores are the same.
They will do a comparing with the score1 first if they are the same will proceed to the next score2 till score4
They will do a comparing with the score1 first if they are the same will proceed to the next score2 till score4
If all 4 scores are the same user can input who won that draw at the end of entering the score.
Michael32 pointsPosted Oct 10, 2005, 3:42 PM EDT
public void Sort(bool largeToSmall){
object obj;
for(int i=1;i<items.Count;i++){
bool test = false;
if(largeToSmall)
test = ((IComparable)items[i]).CompareTo((IComparable)items[i-1])>0;
else
test = ((IComparable)items[i]).CompareTo((IComparable)items[i-1])<0;
if(test){
obj = items[i];
items[i] = items[i-1];
items[i-1] = obj;
i-=2;
}
if(i<0)i=0
}
}
and you compare method says something like
public int CompareTo(object obj){
YourClass class = (YourClass)obj;
if(class.TotalScore<this.TotalScore) return 1;
else if(class.TotalScore>this.TotalScore) return -1;
else{
if(class.Score1<this.Score1) return 1;
else if(class.Score1>this.Score1) return -1;
else{
<<SAME FOR SCORE 2,3,4,5,6,7,... Final else just reads return 0>>
}
}
}
I've written the second bit on the fly so it's might have mistake (like having the < & > the wrong way round but generaly it should work
Solitaire85 pointsPosted Oct 10, 2005, 3:43 PM EDT
Array.Sort(arrayname);
Michael32 pointsPosted Oct 10, 2005, 4:02 PM EDT
eg in an address book if 2 people have the surname Smith the given name is used to determine the order in which they are shown
Nicholas3 pointsPosted Oct 10, 2005, 7:09 PM EDT