Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

BBall statistics You need to complete a class called BBall that will represent a basketball player. Then complete a driver (start with fileStreamtest that I

BBall statistics

You need to complete a class called BBall that will represent a basketball player. Then complete a driver (start with fileStreamtest that I sent you). Use the textfile I emailed you.

The format of testfile is

Number

Lastname

Firstname

2pointshotsmade

2pointshotattempt

3pointshotmade

3pointshot attempt

Foulshotmade

Foulshotattempt

The above data is for the shot (so to get the points you need to multiply 2 * 2pointsmade etc)

You will create a BBall class. Here are the instance variables

number int

lastName String

firstName String

made2 int

att2 int

made3 int

att3 int

made1 int

att1 int

You only need one constructors - one setting all the instance variables.

You do need a setter/getter for each variable.

Make a toString that outputs like:

James DEMERY

Two point percent: 0.4678362573099415

Three point percent: 0.26865671641791045

Foul shot percent: 0.625

When you look at your output you will notice NaN as the output for some players. This is because you are dividing by 0. To fix that(worth extra point on lab) - in the toString you will have 3 if statements - for example before you calculate the 2 point percentage , - you check to see if att2 is greater than 0 - if true, then you add the percentage , if false you just concatenate a 0

Create a driver and test the Class. This will not be turned in.

Then create another driver(based on the filestreamtest) that will make an ArrayList of basketball players

ArrayList team = new ArrayList();

You will read across the line of the input variable by variable and you will then take all these variables and add a BBall player to the arrayList. You will keep doing this until you have read the whole input

The you will read in from the file I emailed you and make the team and calculate some statistics.

Use try-catch to setup input and output Stream.

Declare the variables you need in order to read in data

Inside the while loop

Read in data from file into variables.

b.Add the basketball player to the ArrayList

c.Finish reading the file in/ end loop

4. Print team out to output file

outputStream.println(team);

5.Calculate these statistics for the team and print to output file

The total team points is 2232.00

The two point percent is 41.13

The three point percent is 32.06

The foul shot percent is 66.86

THEN CLOSE THE INPUT and OUTPUT STREAMS!!!!!!

Text file for basketball players:

25 DEMERY James 160 342 18 67 80 128 1 NEWKIRK Shavar 135 354 41 135 119 157 33 FUNK Taylor 103 237 70 173 31 37 0 KIMBLE Lamarr 4 11 2 4 0 1 15 CLOVER Chris 81 207 26 80 22 43 24 OLIVA Pierfrancesc 56 121 12 45 31 64 5 ROBINSON Nick 46 115 6 31 42 55 12 LONGPRE Anthony 34 111 18 56 10 16 22 EDWARDS Lorenzo 10 39 7 32 4 5 10 BLOUNT Gerald 2 2 0 0 0 0 32 WILLIAMS Jai 5 10 0 0 3 5 23 LODGE Markell 5 6 0 0 1 3 3 BOOTH Michael 1 2 1 2 0 0 21 THOMPSON Kyle 0 1 0 0 2 2 11 FREEMAN Toliver 0 2 0 2 0 0 13 VEGA Christian 0 1 0 0 0 0

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

=+3. Do you wat television? If so, how do you do it?

Answered: 1 week ago

Question

Describe new developments in the design of pay structures. page 475

Answered: 1 week ago