Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

use java language. You will be writing a program to track the outcome of a competition or sporting event where individuals or teams receive a

use java language.

You will be writing a program to track the outcome of a competition or sporting event where individuals or teams receive a time and the shortest time is the winner of the race. For example, a bobsled team receives a time and first place is the team with the shortest time. Start by choosing the sporting event you will track and then implement the classes listed below.

1.1 Contestant class

Your contestant class must have the following characteristics:

A meaningful name (i.e. not Contestant)

At least 3 fields such that one field must be id and be of type int. one field must be name and be of type String. This will be your search key. one field must be time and be of type float or double. all fields must be private.

Implement a setter for time.

Implement getters for id, name, and time.

Implement toString() which returns a one line string with all the instance variables.

Implement an equals() method which returns true when the search key is the same regardless of case and the ids are the same.

Implement the Comparable interface. compareTo() returns a negative number when the invoking objects time is less than the arguments time. 0 when the invoking objects time is the same as the arguments time. a positive number when the invoking objects time is greater than the arguments time.

Implement a constructor which has as its argument the value for the id and the name.

1.2 Collection class

Implement a collection class of your Contestant using a list of nodes. You may not use any classes from the Collection package.

The name of your collection class should make sense based on the type of your contestant.

Implement an insert() method which takes as an argument an instance of your Contestant class and inserts it into the linked list in ASCENDING order according to the time.

Implement a size() method which returns an integer representing the number of items in the collection.

Implement a toString() method which returns a string representation of all the items in the collection. It should be formatted as a table with a header row and one item per line.

Implement a find() method which takes as an argument a string and returns the first object in the collection that has a search key which matches.

Implement a countOccurences() method which takes as an argument an instance of your Contestant class and returns the number of objects in the collection which match.

Implement a countRange() method which takes two arguments representing a range of times of the same type as your time field. It should return the number of objects in your class which fall within the range including the values at the end of the range. If the first argument is greater than the second parameter return 0.

Implement a delete() method which takes an instance of your Contestant class, removes the matching instance if it exists. It should return the deleted object if found, null if not found. The order of the collection should be maintained after the delete.

Writee an iterator for your collection.

1.3 Runner class Implement a runner class which includes a test program to:

Create an instance of your collection class.

Use insert() to insert 6-10 items into your collection.

The runner class tests all methods on the collection class.

Do not use Scanner to read inputs from the user. Hard code all values.

2 Other requirements

Draw a UML class and structure diagram which shows the relationship among the classes in your solution. It must be submitted as an image file (e.g. jpg, png).

Use Javadoc style comments for ALL public methods and constructors in your Contestant and Collection classes.

Use good coding style and formatting throughout. Note that Eclipse has a feature to automatically format your code. Use this

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

15-5 How will MIS help my career?

Answered: 1 week ago