Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7537709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T06:55:28+00:00 2026-05-30T06:55:28+00:00

public class AthleteManager { private static Icon anIcon = new ImageIcon(); private static int

  • 0
public class AthleteManager {

private static Icon anIcon = new ImageIcon();
private static int currentSize = 0, maxSize = 10;

private Athlete[] AthleteList = new Athlete[maxSize];

///////////////////////////////////////////////////

public AthleteManager(){

    Runner aRunner = new Runner("Bolt","Jamica",101);
    AthleteList[currentSize]=aRunner;
    currentSize++;

    DuAthlete aDuAthlete = new DuAthlete("Benny", "Belgian", 102);
    AthleteList[currentSize]=aDuAthlete;
    currentSize++;

    TriAthlete aTriAthlete = new TriAthlete("Alexander", "Irish", 103);
    AthleteList[currentSize]=aTriAthlete;
    currentSize++;

    Coach aCoach = new Coach("Wolmer", "Britan",  104);
    AthleteList[currentSize] = aCoach;
    currentSize++;
}

/////////////////////////////////////////////////////////////////////////

public int mainMenu()
{
    int option =0;

    String opt1 = new String("1. Add an Athlete :");
    String opt2 = new String("2. Register an Athlete with a Coach :");
    String opt3 = new String("3. List All members of Team DS 2012 :");
    String opt4 = new String("4. List all Athletes of Coach (based on ID):");
    String opt5 = new String("5. Display Leader Board:");
    String opt6 = new String("6. Search for an Athlete (based on a Name) :");
    String opt7 = new String("7. Remove an Athlete (based on ID):");
    String opt8 = new String("8. Log finishing Distances:");
    String opt9 = new String("9. Exit System");
    String msg = new String("Enter Option:");
    JTextField opt = new JTextField("");

    Object message[] = new Object[12];

    message[0] = myIcon;
    message[1] = opt1;
    message[2] = opt2;
    message[3] = opt3;
    message[4] = opt4;
    message[5] = opt5;
    message[6] = opt6;
    message[7] = opt7;
    message[8] = opt8;
    message[9] = opt9;
    message[10] = msg;
    message[11] = opt;

    int response = JOptionPane.showConfirmDialog(null,message,"Athlete Data Entry",JOptionPane.OK_CANCEL_OPTION,
            JOptionPane.QUESTION_MESSAGE ,anIcon);

    if(response == JOptionPane.CANCEL_OPTION)
        ;
    else
    {
        try {
            option = Integer.parseInt( opt.getText());
        }
        catch (Exception e)
        {
            JOptionPane.showMessageDialog(null,"Data Input Error" + e + "\nPlease Try Again");
        }
    }
    return option;
}
////////////////////////////////////////////////////////////////////////

public void addAthleteMenu(){

    choseAthleteMenu();
}

////////////////////////////////////////////////////////////////////////

public int choseAthleteMenu(){
    int option =0;
    String inform = new String("Please Select the type of athlete");
    String opt1 = new String("1. Runner:");
    String opt2 = new String("2. DuAtlete :");
    String opt3 = new String("3. TriAthlete :");
    String opt4 = new String("4. Coach");
    String msg = new String("Enter Option:");
    JTextField opt = new JTextField("");

    Object message[] = new Object[8];

    message[0] = myIcon;
    message[1] =inform;
    message[2] = opt1;
    message[3] = opt2;
    message[4] = opt3;
    message[5] = opt4;
    message[6] = msg;
    message[7] = opt;

    int response = JOptionPane.showConfirmDialog(null,message,"Athlete Data Entry",JOptionPane.OK_CANCEL_OPTION,
            JOptionPane.QUESTION_MESSAGE ,anIcon);

    if(response == JOptionPane.CANCEL_OPTION)
        ;
    else
    {
        try {
            addRunner();            }
        catch (Exception e)
        {
            JOptionPane.showMessageDialog(null,"Data Input Error" + e + "\nPlease Try Again");
        }
    }
    return option;
}
/////////////////////////////////////

public void addRunner(){
    String msgName = new String("Athlete Name :");
    String msgClubName= new String("Club Name :");
    Integer msgID = new Integer("Athlete ID :");
    String msgDistance = new String("Athlete Distance :");
    JTextField name = new JTextField("");
    JTextField club = new JTextField("");
    JTextField id = new JTextField();
    JTextField distance = new JTextField("");

    Object message[] = new Object[9];

    message[0] = myIcon;
    message[1] = msgName;
    message[2] = name;
    message[3] = msgClubName;
    message[4] = club;
    message[5] = msgID;
    message[6] = id;
    message[7] = msgDistance;
    message[8] = distance;

    int response = JOptionPane.showConfirmDialog(null,message,"Athlete Data Entry",JOptionPane.OK_CANCEL_OPTION,
            JOptionPane.QUESTION_MESSAGE ,anIcon);

    if(response == JOptionPane.CANCEL_OPTION)
        ;
    else
    {
        try{
            Runner nRunner = new Runner();
            nRunner.setName(name.getText());
            nRunner.setClub(club.getText());
            nRunner.setId(Integer.parseInt(id.getText()));

            addRunnerToList(nRunner);
        }
        catch(Exception e){
            JOptionPane.showMessageDialog(null, "Data Input Error" + e + "\nPlease Try Again");

        }
    }
}

///////////////////////////////////////////////////////////////////////////////

private void addRunnerToList(Runner nRunner){

    try{
        AthleteList[currentSize]=nRunner;
        currentSize++;
    }catch(Exception sqle){

        JOptionPane.showMessageDialog(null, "Can Not Add to List" +sqle);
    }

}

///////////////////////////////////////////////////////////////////////////

public void menuListAthletes(){

    JOptionPane.showMessageDialog(null, AthleteList);
}

////////////////////////////////////////////////
public void regAnAthleteWithCoachMenu(){

}


//////////////////////////////////////////
public void listAthletesOfCoach(){

}
///////////////////////////////////
public void leaderBoard(){

}

//////////////////////////////////////////

public void searchAthlete(){

}
//////////////////////////////////////
public void removeAthlete(){

}
//////////////////////////////////

public void logDistances(){

}
//////////////////////////////////
}

What I’m trying to do is add different types of atlete by using the JTextfield, in the above code rather than writing a separate method for adding each type of athlete is there a way that when an option is selected from the the choseAthleteMenu() menu method that using some sort of check athletes can be added to their relevant places?
Any advice?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T06:55:29+00:00Added an answer on May 30, 2026 at 6:55 am

    My idea would be to have the different types of Athletes implement a interface and then pass it to addrunner under that interface with the user input of which athlete to create. Don’t want to solve the whole thing for you but maybe that will help you out.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

public class StaticTest { private static StaticTest stObj=new StaticTest(); private static int VAR1=10; private
public class Bird { private static int id = 0; private String kind; public
public class Bird { private static int id = 0; private String kind; public
public class Sprite { private static final int BMP_COLUMNS = 3; private static final
public class SelfCallingTest { private static int counter; public void SelfCallingMethod(int counter) { Console.WriteLine(The
public class Checker { static private int value1 = 0, value2 = 1; static
public class CovariantTest { public A getObj() { return new A(); } public static
public class WrapperTest { static { print(10); } static void print(int x) { System.out.println(x);
public class Employee { public static void main(String[] args) { int j=3; staples[] stemp
public class InterruptedInput { public static void main(String[] args) { InputThread th=new InputThread(); //worker

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.