Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use java language. if you do not know the solution plz do not answer. This all the information i have. Program 2: Objective In this

Use java language. if you do not know the solution plz do not answer. This all the information i have.

Program 2:

Objective In this assignment you will create an ordered list using only an array. This will teach you how to do basic object comparison and sorting.

1 Program Description

You will be writing a program to track the outcome of a competition or sporting event where individuals or teams receive a score and the winner is the highest score. For example, a pair of figure skaters receive a score for their performance and the pair with the highest score wins. 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 score and be of type float or double. all fields must be private.

Implement a setter for score.

Implement getters for id, name, and score.

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 score is less than the arguments score. 0 when the invoking objects score is the same as the arguments score. a positive number when the invoking objects score is greater than the arguments score.

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 an array. 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 a constructor with no arguments which sets a default initial size for the underlying array.

Implement a constructor with one argument which represents the initial size of the underlying array.

Implement an insert() method which takes as an argument an instance of your Contestant class and inserts it into the underlying array in DESCENDING order according to the score. If the array is full, create a new larger array, copy the values from the old array to the new array, delete the old array, and then insert the new object.

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 scores of the same type as your score 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.

Write an iterator for your collection.

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

Create a collection class with default value of 5

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. 3 Grading criteria

Programs that do not compile and run without error will receive 0 points.

Your program must meet all specifications outlined above.

You must use the exact same name for all methods outlined above. Beware of the casing.

UML diagram is submitted and matches the code.

Your code is commented where appropriate.

Create your UML diagram before you being coding.

5 Tips for success

Do not use == for comparison.

Start early and bring your questions to class.

Create your UML diagram before you being coding.

If you get stuck write out the problem in plain English or in pseudo code

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

Beginning C# 2005 Databases

Authors: Karli Watson

1st Edition

0470044063, 978-0470044063

More Books

Students also viewed these Databases questions

Question

Find the derivative. f(x) 8 3 4 mix X O 4 x32 4 x32 3 -4x - x2

Answered: 1 week ago