Yurttas/PL/OOL/Java/F/09/02/01/00/Swimmer.java

From ZCubes Wiki
Jump to navigation Jump to search
 1import java.util.*;
 2
 3public class Swimmer {  
 4   private String firstName, lastName;
 5   private int age;
 6   private String club;
 7   private float time;
 8   
 9   private int heat, lane;
10//--------------------------------------
11   public Swimmer(String dataline)  {
12   StringTokenizer st = new StringTokenizer(dataline, " ");
13   String lineNumber = st.nextToken();    //ignore and discard
14   firstName = st.nextToken();
15   lastName = st.nextToken();
16   age = new Integer(st.nextToken().trim()).intValue();
17   club = st.nextToken().trim();
18   
19   String stime = st.nextToken().trim();
20   int i = stime.indexOf(":");
21   if (i > 0) {
22      stime = stime.substring(0, i) + stime.substring(i+1);
23   }
24   time = new Float(stime).floatValue();
25   
26   }
27   
28   //-------------------------------
29   public void setLane(int ln) {
30      lane = ln;
31   }
32   //-------------------------------
33   public int getLane() {
34      return lane;
35   }
36   //-------------------------------
37   public void setHeat(int ht) {
38      heat = ht;
39   }
40   //-------------------------------
41   public int getHeat() {
42      return heat;
43   }
44   //-------------------------------
45   public int getAge() {
46      return age;
47   }
48   //-------------------------------
49   public float getTime() {
50      return time;
51   }
52   //-------------------------------
53   public String getName() {
54      return firstName+" "+lastName;
55   }
56   //-------------------------------
57   public String getClub() {
58      return club;
59   }
60}