Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA ONLY You will be creating a JUnit Test Class for Gradebook . java (provided). Gradebook has two attributes: an array of int called scores

JAVA ONLY

image text in transcribedimage text in transcribedimage text in transcribed

You will be creating a JUnit Test Class for Gradebook . java (provided). Gradebook has two attributes: an array of int called scores to hold scores and scoresize that indicates how many scores are currently held in the array. This field is initially set to 0 . Task \#1: 1. Add a getScoreSize() method to the Gradebook class which returns scoresSize; 2. Add a toString() method to the Gradebook class that returns a string with each score in scores field of the Gradebook separated by a space. Task \#2: Create the Test Class GradebookTester by right clicking on the GradeBook.java, select New, Junit Test Case. Using the wizard: 1. Select the setUp and tearDown method check boxes and click Next. 2. Select all of the methods of Gradebook, except for the constructor to create tests for. Then click finish. Task \#3: 1. In the setUp method of GradebookTester, create at least two objects of Gradebook to hold 5 scores. Then call the addscore method for each of the Gradebook objects at least twice (but no more than 5 times) to add some random scores of your choice to the GradeBook objects 2. In the teardown method of GradebookTester, set the two objects of Gradebook to null. 'ask \#4: Create test for the methods of Gradebook: 1. addScore - Use the toString method to compare the contents of what is in the scores array vs. what is expected to be in the scores array assertirue( (..) - Compare the scoresize to the expected number of scores entered, using asserttguals(...) 2. sum - Compare what is returned by sum() to the expected sum of the scores entered. 3. minimum - Compare what is returned by minimum() to the expected minimum of the scores entered. 4. finalscore - Compare what is returned by finalscore() to the expected finalscore of the scores entered. The finalScore is the sum of the scores, with the lowest score dropped if there are at least two scores, or 0 if there are no scores. Example: As a private attribute (member) of GradeBookTest: GradeBook gl; In setup: g1 = new GradeBook (5); g1.addScore (50); g 1.addScore(75); In teardown: g1=null; in testSum(: assertequals (125, g1.sum(), .0001); in testMinimum(): assertEquals (50, 91.minimum (), .001); in addScoreTest(); assertTrue(g1.tostring().equals("50.075.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

Students also viewed these Databases questions

Question

1. Administrative services, such as wages.

Answered: 1 week ago

Question

Calculate the lifetime value (LTV) of a loyal customer.

Answered: 1 week ago

Question

Use service tiering to manage the customer base and build loyalty.

Answered: 1 week ago