Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

NOTE: For this lab, you will get 5 points for a valid attempt if turned in by the due date. The main new functionality in

NOTE: For this lab, you will get 5 points for a valid attempt if turned in by the due date.

The main new functionality in this lab was reviewed in class with the introduction of Generics.

1. SUMMARY

a.

Using Javas Generics framework, make two classes... one that stores 2 items of any given type (Pair)

and one that stores 3 items of any given type (Triple). Then use the triple value class to store the win

& loss records of multiple football teams (or any sport) in an array. Next loop through array and

calculate the winning percentage of each team and add team name and win % to a pair class, and

then add that instance to another array. Finally print out all team entries in the pair array with their

win percentages and state which team has the greatest win percentage.

b. This lab will involve the following new features:

i. Generics

2. DETAILS

a.

Generic classes: Youll make two classes similar to what we did in class.

i. One class is the Pair class just like from class, and the other will be a Triple class and will have one

more parameter, so A,B,C in the Triple class.

b. In your main class, you will create at least 5 instances of the Triple class, and in each one you will

store:

i. Team name String

ii. Wins int

iii. Losses int

c.

Create an array of this Triple generic class type and store these 5 instances in the array.

i. Here is a guide on creating an array of generic types:

Triple[] aoTriple;

aoTriple = new Triple[5];

d. Now create another array of Pair type that is 5 in length.

e. Create a for loop and loop through the Triple array.

i. For each item, calculate the win percentage and create new Pair object and place following values

in each Pair object:

1. Team name String

2. Winning percentage double (e.g. .67) this has to be calculated as opposed to just typing it

into code!

a.

NOTE: Winning percentage has to be calculated by dividing wins by total games and can

just be stored as a decimal... e.g. .85

f.

Print out results:

i. Finally create a for loop to loop through Pair array and print out the values of each object (team

name and win %).

ii. IMPORTANT: Also print out which team has the

highest win %

by figuring out mathematically

which % is the highest.

Use IntellJ Please

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

Expert Performance Indexing In SQL Server

Authors: Jason Strate, Grant Fritchey

2nd Edition

1484211189, 9781484211182

More Books

Students also viewed these Databases questions