The Artima Developer Community
Sponsored Link

Java Answers Forum
Help with data structures

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
ray gibson

Posts: 1
Nickname: jahlive
Registered: Apr, 2005

Help with data structures Posted: Apr 28, 2005 5:20 PM
Reply to this message Reply
Advertisement
I am creating a simple program to hold competitor details for a ski race competition after every race, a time is entered, and the results is sorted with the least time as position one, am not using realtime but int or double, I've got a suggestion to use arrays rather than a Vector, am not sure how to store the competitors time so that if a new time is entered the result and their position can be sorted any advice. below is my competitor class.

package skiracescoreboard04_05;

public class Competitor
{
private String compNo;
private String name;
private String country;
private double result;
private int position;

public Competitor()//default constructor
{
this.compNo = "9999";
this.name = "No Name";
this.country = "N/A";
this.position = 00;
result = -1; // to signify no result yet
}


public Competitor(String compNo, String name, String country)//result and position is not yet achieved
{
this.compNo = compNo;
this.name = name;
this.country = country;
this.position = position;
result = -1; // to signify no result yet
}

public void addResult(double result)
{
this.result = result;
}

public String getCompNo()
{
return compNo;
}

public String getName()
{
return name;
}

public String getCountry()
{
return country;
}

public double getResult()
{
return result;
}

public int getPosition()
{
return position;
}

public boolean hasResult()
{
return result != -1;
}

public String toString()
{
return "\t" + compNo +"\t" + name.toUpperCase() +"\t"+ country.toUpperCase() +"\t " + result +"\t " + position;
}

public boolean hasCompNo(String aCompNo)
{
return compNo.equals(aCompNo);
}

} // end of class Competitor

Topic: Editing in a JList Previous Topic   Next Topic Topic: I neeed help on java compiler

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use