Question: Need help with Java programming language Resistance Is Futile Overview You will be developing one class and one test class. The class creates a simple

Need help with Java programming language

Resistance Is Futile

Overview

You will be developing one class and one test class. The class creates a simple model of a basic electronic component and its behaviors. The basic formulas you will need to use to complete the model are explained and provided within this document.

Resistor Class

Create a class called Resistor

The class has the following maxResistance and minResistance methods that returns a value that is a function of a resistance property and a tolerance property. As an example, if the resistance is 10000, and the tolerance is 0.10, then:

Maximum resistance = 10000 * (1.0 + 0.10) = 11000

and

Minimum resistance = 10000 * (1.0 - 0.10) = 9000

public double maxResistance(double resistanceOhms, double tolerance)

public double minResistance(double resistanceOhms, double tolerance )

The class also has a powerDissipated method. The following formula calculates the power dissipated by the resistor for a given current the result of which should be returned. If the calculated pd exceeds the resistors power rating, then -1 is returned instead.

pd = (current value ^ 2) * maximum resistance value

or

pd = current value * current value * maximum resistance value

Example: if resistanceOhms=100 tolerance=.1 powerRating = 1000 current = 2.3; then Pd = 581.9 and is returned

double powerDissipation(double resistanceOhms, double tolerance, double powerRating, double current)

ResistorTest Class

Create a JUnit test class called ResistorTest

The easiest way to do this is right clicking the project on the package explorer then New -> JUnit Test Case -> Set name to ResistorTest -> Set Class Under Test to Resistor

Then create test methods named

@Test void maxResistanceTest() - which tests the calculation of the max resistance

@Test void minResistanceTest() - which tests the calculation of the min resistance

@Test void powerDissipatedTest() - which tests the calculation of pd when the resistors power rating is not exceeded

@Test void powerDissipatedOverloadTest() - which tests the calculation of pd when the resistors power rating is exceeded

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!