Question
Hello! Im new to testing in Java and I need some help. Please take the time to explain things to me so I could understand
Hello! Im new to testing in Java and I need some help. Please take the time to explain things to me so I could understand it more. Thanks.
Here is what I have to do
1. Use assertNotNull() to test the Complex(double, double) constructor
2. Use assertEquals(double, double, double) to test if getReal() returns the correct value set using the Complex(int, int) constructor
3. Use assertEquals(double, double, double) to test if setReal() correctly resets the value set using the Complex(double, double) constructor
4. Use the no-arg Complex() constructor, and then use the real and imaginary setters to set new integer values. Then use assertTrue(boolean) to test the validity of your newly-added equals(int, int) method
5. Using assertTrue(boolean), test that two Complex numbers created using the Complex(String[]) constructor and the Complex(String, String) constructor give the correct result using the multiply() method. Use equals(Complex) to compare the actual and expected result
6. Divide two Complex numbers and use the result to test your equals(double expected, double actual, double delta) method, with delta = .0000001
Here is my class code
Here is my attempt of doing it
eclipse-workspace-CS18284-Lab04/src/cst8284/calculator/Complexava-Eclipse File Edit Scurce Refatr Navigate Search Preject Rur Winduw Help 1 package cst8284.calculator 3 public class Conplex \ private double real = e; privata doublo ina // Complex ranstructor that takrs in a single string, r.E- 2-4i. 9 public Conplex(String Str this(cstr.split"?V)"): splits cstr ator into an array of strings having two elenents The first elenrnt of thr resultant array wil1 he the rral portion, while the second is the imaginary porLio This array is passed to Lhe riext constructor 12 13 14 Complex constructor that takes in an array of two strings fron the above constructor 17 1 public Conplex(String] cStr) 19 this(cStr[el, cstr[11); 21 23 Conplex ranstructor that takrs two separate strings as parameters, r.g. "" and Ai" 24 public Conplex(Strirng r, String i) this(Integer parseint(r), Integer parselnt(i.replace"))) 06 Complex ronstructor that takrs in tun ints as paraneters, .e-2 and- public Conplex(int r, int i) 31 this (double)r, (double)i); 34 // Complex ranstructor that takes in tun ints and stares then as floats, r.E- as ).e and .4. 6 public Conplex(double , double i) 3/ this.setReal(r); this-set Tmng(1 ) ; 11 idefault Complex constructorg it should rhain autonatically 42 public Conplex)this(,8); 45 public double getReal Smart Insert71: 109Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started