Question

Description: You have been asked to help the College of IST Running Club by designing a...

Description:

You have been asked to help the College of IST Running Club by designing a program to help them keep track of runners in the club, the races that will occur, and each runner's performance in each race!

Requirements:

Please use Java to implement the program

Your program must:

  • Store information about each Runner.
  • Store information about each Race.
  • Store information about the performance of each runner in each race that they compete in. Note that each race may have many runners, and each runner may compete in many races.

-----------------

Step 1: Your Runner class.

- Create a Runner class that stores runner ID, first name, last name, gender, and age.

- Override toString() to properly display all attributes.

- Create all constructors, getters, and setters as necessary

-----------------

Step 2: Your Race class.

- Create a Race class that stores race ID, race location, and race date.

- Override toString() to properly display all attributes.

- Create all constructors, getters, and setters as necessary

-----------------

Step 3: Connecting Runners and Races

- In addition to simply storing information about runners and races as described above, we must store the following data:

  • The list of runners participating in each race
  • The list of races participated in by each runner
  • The finishing time of each runner in each race
  • The finishing position of each runner in each race

Note that there are a few ways to accomplish this. you will be graded (in part) on the quality of your design choices. This may include the creation of another class/classes or the use of other data structures. NOTE: You may not use a Map data structure for this assignment.

-----------------

Step 4: Your RunningClub class.

- Create a RunningClub class that leverages the classes we created earlier in order to provide the following methods:

  • addRunner() : Adds a runner to the club. It should take the runner ID, first name, last name, gender, and age as parameters. It should succeed (and return true) if the runner ID parameter doesn't already exist, and fail (and return false) otherwise.
  • addRace(): Adds a race. It should take the race ID, race location, and race date as parameters. It should succeed (and return true) if the race ID parameter doesn't already exist, and fail (and return false) otherwise.
  • recordCompletedRace(): Records information about the completion of a race. The parameters will vary depending on your implementation choices, but it should record the runner, the race, the finishing time of that runner in that race, and the finishing position of that runner in that race.
  • showAll(): Displays all runners, all races, and all information about completed races.

-----------------

Step 5: Your main() method

In your main method:

  • Create an instance of your RunningClub class
  • Use the addRunner() method (repeatedly) to add 2 runners.
  • Use the addRace() method (repeatedly) to add 3 races.
  • Use the recordCompletedRace() method (repeatedly) to record each runner completing at least 2 races.
  • Use the showAll() method to display all information in the system.

-----------------

Step 6: Create a UML Class diagram for all of your classes.

Your diagram should use the three-block structure shown in class (with Name, Attributes, and Methods), label associations, and include multiplicity. You may draw your diagram on paper and take a picture, or use another tool.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Runner class:

public class Runner {
   private static Runner[] idlist=new Runner[1000];//max 1000 runners possible
   private static int count=0;
   private int id;
   private String firstName;
   private String secondName;
   private char gender;//takes 'm' for male and 'f' for female
   private int age;//takes values from 6 to 100
   private int racecount=0;


   public int getid()
   {
       return this.id;

   }

   public String getfirstName()
   {
       return this.firstName;
   }

   public String getsecondName()
   {
       return this.secondName;
   }

   public char getgender()
   {
       return this.gender;
   }

   public int getage()
   {
       return this.age;
   }

   public String toString()
   {
       String ans = "ID :"+this.id+"\n"+"Name: "+this.firstName+" "+this.secondName+"\n"+"Age: "+this.age+"\n"+"Gender: "+this.gender;
       return ans;
   }
   public Runner[] getidlist()
   {
       return this.idlist;
   }
  

   public Runner(int id,String firstName,String secondName,char gender,int age ) throws ErrorCase
   {
       if (count==1000)
           {
               System.out.println("Max runners filled! ");
               throw new ErrorCase();
           }
       if (age<=100 && age>6 && (gender=='m' || gender=='f'))
       {
           for(int i=0;i<count;i++)
               {
                   if (idlist[i].getid()==id)
                       System.out.println("ID already present!");
                   throw new ErrorCase();
               }
           this.firstName = firstName;
           this.secondName = secondName;
           this.age=age;
           this.gender=gender;
           this.id = id;
           idlist[count]=this;
           count++;
       }
       else
       {
           throw new ErrorCase();
       }

   }

}

Race class:

public class Race{
   private static Race[] idlist=new Race[1000];//max 1000 races possible
   private static int count=0;
   private int id;
   private String location;
   private String date;//Format "dd/mm/yyyy" a,check condition is not being added here.
   private static double[][] stats = new double[1000][3];
   private static int statcount=0;

   public int getid()
   {
       return this.id;

   }

   public String getlocation()
   {
       return this.location;
   }
   public String getdate()
   {
       return this.date;
   }
   public static boolean addstats(int id,double time,int pos)
   {
       stats[statcount][0]=id;
       stats[statcount][1]=time;
       stats[statcount][2]=pos;
       statcount++;
       return true;
   }
   public static double[][] getstats()
   {
       return stats;
   }
   public static int getcount()
   {
       return count;
   }
   public static Race[] getidlist()
   {
       return idlist;
   }
   public Race(int id,String location,String date) throws ErrorCase
   {
       if (count==1000)
           {
               System.out.println("Max runners filled! ");
               throw new ErrorCase();
           }

       for(int i=0;i<count;i++)
           {
               if (idlist[i].getid()==id)
                   System.out.println("ID already present!");
               throw new ErrorCase();
              
           }
       this.id=id;
       idlist[count]=this;
       count++;
       this.location=location;
       this.date=date;
   }

}

ErrorCase class(I made it for an implementation purpose):

public class ErrorCase extends Exception{
   public String toString()
   {
       return "Something wrong with your input, check!";
   }
}

RunningClub class:

public class RunningClub{
   public static boolean addRunner(int id,String firstName,String secondName,char gender,int age)
   {
       try
       {
           Runner var = new Runner(id,firstName,secondName,gender,age);
           return true;

       }
       catch(ErrorCase e)
       {
           return false;
       }
   }
   public static boolean addRace(int id,String location,String date)
   {
       try
       {
           Race ver = new Race(id,location,date);
           return true;
       }
       catch(ErrorCase e)
       {
           return false;
       }
   }

   public static void recordCompletedRace(int runnerid,int raceid,double time,int pos)
   {
       for(int i=0;i<Race.getcount();i++)
       {
           if (Race.getidlist()[i].getid()==raceid)
           {
               Race.getidlist()[i].addstats(runnerid,time,pos);
           }

       }
   }
   public double[][] showAll()
   {
       return Race.getstats();
   }
}

These four class must be in the same file. Main.java is obvious and the UML diagram can be made from the class definition itself.

Add a comment
Know the answer?
Add Answer to:
Description: You have been asked to help the College of IST Running Club by designing a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • The project description As a programmer; you have been asked to write a program for a Hospital wi...

    program Java oop The project description As a programmer; you have been asked to write a program for a Hospital with the following The Hospital has several employees and each one of them has an ID, name, address, mobile number, email and salary. . The employees are divided into Administration staff: who have in addition to the previous information their position. Nurse: who have their rank and specialty stored in addition to the previous o o Doctor: who have the...

  • program Java oop The project description As a programmer; you have been asked to write a...

    program Java oop The project description As a programmer; you have been asked to write a program for a Hospital with the following The Hospital has several employees and each one of them has an ID, name, address, mobile number, email and salary. . The employees are divided into Administration staff: who have in addition to the previous information their position. Nurse: who have their rank and specialty stored in addition to the previous o o Doctor: who have the...

  • In Java Kindly be sure to take in user input and store the 3 worker classes...

    In Java Kindly be sure to take in user input and store the 3 worker classes in an ArrayList Create a class Worker. Your Worker class should include the following attributes as String variables: Name, Worker ID, Worker Address, Worker City, Worker State Create the constructor that initializes the above worker attributes. Then make another class name HourlyWorker that inherits from the Worker class.   HourlyWorker has to use the inherited parent class variables and add in hourlySalary and billableHours. Your...

  • write in java and please code the four classes with the requirements instructed You will be...

    write in java and please code the four classes with the requirements instructed You will be writing a multiclass user management system using the java. Create a program that implements a minimum of four classes. The classes must include: 1. Employee Class with the attributes of Employee ID, First Name, Middle Initial, Last Name, Date of Employment. 2. Employee Type Class that has two instances of EmployeeType objects: salaried and hourly. Each object will have methods that calculates employees payrol...

  • You will create an Microsoft Access School Management System Database that can be used to store,...

    You will create an Microsoft Access School Management System Database that can be used to store, retrieve update and delete the staff/student. Design an Access database to maintain information about school staff and students satisfying the following properties: 1. The staff should have the following: ID#, name, and classes they are teaching 2. The student should have the following: ID#, name, section, class 3. Create a module containing the section, subject and teacher information 4. Create a module containing student...

  • **Using NetBeans** Lesson Using inheritance to reuse classes. Deliverables person.java student.java studentAthlete.java app.java Using inheritance and...

    **Using NetBeans** Lesson Using inheritance to reuse classes. Deliverables person.java student.java studentAthlete.java app.java Using inheritance and the classes (below) The person class has first name last name age hometown a method called getInfo() that returns all attributes from person as a String The student class is a person with an id and a major and a GPA student has to call super passing the parameters for the super class constructor a method called getInfo() that returns all attributes from student...

  • In Java Create a class Worker. Your Worker class should include the following attributes as String...

    In Java Create a class Worker. Your Worker class should include the following attributes as String variables: Name, Worker ID, Worker Address, Worker City, Worker State Create the constructor that initializes the above worker attributes. Then make another class name HourlyWorker that inherits from the Worker class.   HourlyWOrker has to use the inherited parent class variables and add in hourlySalary and billableHours. Your HourlyWorker class should contain a constructor that calls the constructor from the Worker class to initialize the...

  • IN JAVA USING ECLIPSE The objective of this assignment is to create your own hash table...

    IN JAVA USING ECLIPSE The objective of this assignment is to create your own hash table class to hold employees and their ID numbers. You'll create an employee class to hold each person's key (id number) and value (name). Flow of the main program: Create an instance of your hash table class in your main method. Read in the Employees.txt file and store the names and ID numbers into Employee objects and store those in your hash table using the...

  • Create the Python code for a program adhering to the following specifications. Write an Employee class...

    Create the Python code for a program adhering to the following specifications. Write an Employee class that keeps data attributes for the following pieces of information: - Employee Name (a string) - Employee Number (a string) Make sure to create all the accessor, mutator, and __str__ methods for the object. Next, write a class named ProductionWorker that is a subclass of the Employee class. The ProductionWorker class should keep data attributes for the following information: - Shift number (an integer,...

  • 5: Assume that a Sports Club at the University wishes to store details about its members....

    5: Assume that a Sports Club at the University wishes to store details about its members. Design and implement a Java application to support this requirement. The application should be able to print out and manage information about the members of the club. The following guidelines should be used to construct the applicatiorn a: A Java class, called Member, should be defined to store and manage member details. The class should include methods for updating member details and querying their...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT