Hi,
In need of some help as I have been playing around all day trying to get this to increase the value of number by one after each new runner is added. Anybody able to help me get the value of number to increase after each record is added?
public class Runner { /* static variables */ /* instance variables */ private int number; // runner's number private String name; // runner's name private String ageGroup; // standard, junior or senior private int time; // runner's marathon time in minutes private int nextNumber; // next avaliable number /** * Default constructor for objects of class Runner. */ public Runner() { super(); this.name = ""; this.ageGroup = "standard"; this.time = 0; this.nextNumber = 1; this.number = this.nextNumber + 1; } /* instance methods */ //Only those accessor methods that you will need have been included /** * Returns the receiver's number. */ public int getNumber() { return this.number; } /** * Sets the receiver's name. */ public void setName(String aName) { this.name = aName; } /** * Returns the receiver's name. */ public String getName() { return this.name; } /** * Sets the receiver's ageGroup. */ public void setAgeGroup(String group) { this.ageGroup = group; } /** * Returns the receiver's ageGroup. */ public String getAgeGroup() { return this.ageGroup; } /** * Sets the receiver's time. */ public void setTime(int aTime) { this.time = aTime; } /** * Returns the receiver's time. */ public int getTime() { return this.time; } }
Any help would be great!
Cheers.