SlideShare a Scribd company logo
1 of 3
Download to read offline
Hi,
I have modified the Point.java file as per your requirement.
Point.java
public class Point
{
double x, y;
public Point() {
x = 0;
y = 0;
}
public Point(double x, double y) {
this.x = x;
this.y = y;
}
public double getX() { return x; }
public double getY() { return y; }
public double getRadius() { return Math.sqrt(x * x + y * y); }
public double getAngle() { return Math.atan2(y, x); }
}
import org.junit.*;
import static org.junit.Assert.*;
public class PointTest
{
private static final double TOLERANCE = 1E-12;
@Test public void testNoArg()
{
Point p = new Point();
assertEquals(0, p.getX(), TOLERANCE);
assertEquals(0, p.getY(), TOLERANCE);
assertEquals(0, p.getRadius(), TOLERANCE);
assertEquals(0, p.getAngle(), TOLERANCE);
}
@Test public void testXY()
{
Point p = new Point(3, 4);
assertEquals(3, p.getX(), TOLERANCE);
assertEquals(4, p.getY(), TOLERANCE);
assertEquals(5, p.getRadius(), TOLERANCE);
assertEquals(0.9272952180016122, p.getAngle(), TOLERANCE);
}
}
Solution
Hi,
I have modified the Point.java file as per your requirement.
Point.java
public class Point
{
double x, y;
public Point() {
x = 0;
y = 0;
}
public Point(double x, double y) {
this.x = x;
this.y = y;
}
public double getX() { return x; }
public double getY() { return y; }
public double getRadius() { return Math.sqrt(x * x + y * y); }
public double getAngle() { return Math.atan2(y, x); }
}
import org.junit.*;
import static org.junit.Assert.*;
public class PointTest
{
private static final double TOLERANCE = 1E-12;
@Test public void testNoArg()
{
Point p = new Point();
assertEquals(0, p.getX(), TOLERANCE);
assertEquals(0, p.getY(), TOLERANCE);
assertEquals(0, p.getRadius(), TOLERANCE);
assertEquals(0, p.getAngle(), TOLERANCE);
}
@Test public void testXY()
{
Point p = new Point(3, 4);
assertEquals(3, p.getX(), TOLERANCE);
assertEquals(4, p.getY(), TOLERANCE);
assertEquals(5, p.getRadius(), TOLERANCE);
assertEquals(0.9272952180016122, p.getAngle(), TOLERANCE);
}
}

More Related Content

Similar to Hi,I have modified the Point.java file as per your requirement.P.pdf

Please help!!I wanted to know how to add a high score to this prog.pdf
Please help!!I wanted to know how to add a high score to this prog.pdfPlease help!!I wanted to know how to add a high score to this prog.pdf
Please help!!I wanted to know how to add a high score to this prog.pdf
JUSTSTYLISH3B2MOHALI
 
Java code to find the closest pair using divide and conquer algorith.pdf
Java code to find the closest pair using divide and conquer algorith.pdfJava code to find the closest pair using divide and conquer algorith.pdf
Java code to find the closest pair using divide and conquer algorith.pdf
fashioncollection2
 
Having a problem figuring out where my errors are- The code is not run.pdf
Having a problem figuring out where my errors are- The code is not run.pdfHaving a problem figuring out where my errors are- The code is not run.pdf
Having a problem figuring out where my errors are- The code is not run.pdf
NicholasflqStewartl
 
Martian Cubics and Unit TestingYou must implement all of the data .pdf
Martian Cubics and Unit TestingYou must implement all of the data .pdfMartian Cubics and Unit TestingYou must implement all of the data .pdf
Martian Cubics and Unit TestingYou must implement all of the data .pdf
ellanorfelicityri239
 
Joose @jsconf
Joose @jsconfJoose @jsconf
Joose @jsconf
malteubl
 
Create a class named Point that represent points in in three dimension.docx
Create a class named Point that represent points in in three dimension.docxCreate a class named Point that represent points in in three dimension.docx
Create a class named Point that represent points in in three dimension.docx
earleanp
 
Main class --------------------------import java.awt.FlowLayout.pdf
Main class --------------------------import java.awt.FlowLayout.pdfMain class --------------------------import java.awt.FlowLayout.pdf
Main class --------------------------import java.awt.FlowLayout.pdf
anushkaent7
 

Similar to Hi,I have modified the Point.java file as per your requirement.P.pdf (20)

662305 10
662305 10662305 10
662305 10
 
Please help!!I wanted to know how to add a high score to this prog.pdf
Please help!!I wanted to know how to add a high score to this prog.pdfPlease help!!I wanted to know how to add a high score to this prog.pdf
Please help!!I wanted to know how to add a high score to this prog.pdf
 
Operator overloading (binary)
Operator overloading (binary)Operator overloading (binary)
Operator overloading (binary)
 
Migrating to JUnit 5
Migrating to JUnit 5Migrating to JUnit 5
Migrating to JUnit 5
 
CSharp v1.0.2
CSharp v1.0.2CSharp v1.0.2
CSharp v1.0.2
 
AJUG April 2011 Cascading example
AJUG April 2011 Cascading exampleAJUG April 2011 Cascading example
AJUG April 2011 Cascading example
 
C# Starter L06-Delegates, Event Handling and Extension Methods
C# Starter L06-Delegates, Event Handling and Extension MethodsC# Starter L06-Delegates, Event Handling and Extension Methods
C# Starter L06-Delegates, Event Handling and Extension Methods
 
Java code to find the closest pair using divide and conquer algorith.pdf
Java code to find the closest pair using divide and conquer algorith.pdfJava code to find the closest pair using divide and conquer algorith.pdf
Java code to find the closest pair using divide and conquer algorith.pdf
 
662305 11
662305 11662305 11
662305 11
 
culadora cientifica en java
culadora cientifica en javaculadora cientifica en java
culadora cientifica en java
 
Lecture 6.pptx
Lecture 6.pptxLecture 6.pptx
Lecture 6.pptx
 
Having a problem figuring out where my errors are- The code is not run.pdf
Having a problem figuring out where my errors are- The code is not run.pdfHaving a problem figuring out where my errors are- The code is not run.pdf
Having a problem figuring out where my errors are- The code is not run.pdf
 
Modul Praktek Java OOP
Modul Praktek Java OOP Modul Praktek Java OOP
Modul Praktek Java OOP
 
Martian Cubics and Unit TestingYou must implement all of the data .pdf
Martian Cubics and Unit TestingYou must implement all of the data .pdfMartian Cubics and Unit TestingYou must implement all of the data .pdf
Martian Cubics and Unit TestingYou must implement all of the data .pdf
 
Java: Nie popełniaj tych błędów!
Java: Nie popełniaj tych błędów!Java: Nie popełniaj tych błędów!
Java: Nie popełniaj tych błędów!
 
Scala in practice
Scala in practiceScala in practice
Scala in practice
 
Joose @jsconf
Joose @jsconfJoose @jsconf
Joose @jsconf
 
Create a class named Point that represent points in in three dimension.docx
Create a class named Point that represent points in in three dimension.docxCreate a class named Point that represent points in in three dimension.docx
Create a class named Point that represent points in in three dimension.docx
 
This is to test a balanced tree. I need help testing an unbalanced t.pdf
This is to test a balanced tree. I need help testing an unbalanced t.pdfThis is to test a balanced tree. I need help testing an unbalanced t.pdf
This is to test a balanced tree. I need help testing an unbalanced t.pdf
 
Main class --------------------------import java.awt.FlowLayout.pdf
Main class --------------------------import java.awt.FlowLayout.pdfMain class --------------------------import java.awt.FlowLayout.pdf
Main class --------------------------import java.awt.FlowLayout.pdf
 

More from anokhijew

Liquid crystals (LCs) are a state of matter that .pdf
                     Liquid crystals (LCs) are a state of matter that .pdf                     Liquid crystals (LCs) are a state of matter that .pdf
Liquid crystals (LCs) are a state of matter that .pdf
anokhijew
 
The Data recovery is of two types …One method is by using a softwa.pdf
The Data recovery is of two types …One method is by using a softwa.pdfThe Data recovery is of two types …One method is by using a softwa.pdf
The Data recovery is of two types …One method is by using a softwa.pdf
anokhijew
 
StudentData.javaimport java.util.Scanner; public class Student.pdf
StudentData.javaimport java.util.Scanner; public class Student.pdfStudentData.javaimport java.util.Scanner; public class Student.pdf
StudentData.javaimport java.util.Scanner; public class Student.pdf
anokhijew
 
Reverse EngineeringReverse engineering is also a back engineering .pdf
Reverse EngineeringReverse engineering is also a back engineering .pdfReverse EngineeringReverse engineering is also a back engineering .pdf
Reverse EngineeringReverse engineering is also a back engineering .pdf
anokhijew
 
Quantum mechanics predicts the existence of what are usually called .pdf
Quantum mechanics predicts the existence of what are usually called .pdfQuantum mechanics predicts the existence of what are usually called .pdf
Quantum mechanics predicts the existence of what are usually called .pdf
anokhijew
 
Program Educational Objectives • To create competencies and opportun.pdf
Program Educational Objectives • To create competencies and opportun.pdfProgram Educational Objectives • To create competencies and opportun.pdf
Program Educational Objectives • To create competencies and opportun.pdf
anokhijew
 

More from anokhijew (20)

we know that there is an OH group present in phen.pdf
                     we know that there is an OH group present in phen.pdf                     we know that there is an OH group present in phen.pdf
we know that there is an OH group present in phen.pdf
 
systems T and P are different from the reservoi.pdf
                     systems T and P are different from the reservoi.pdf                     systems T and P are different from the reservoi.pdf
systems T and P are different from the reservoi.pdf
 
Since X represents the solid phase, Y represents .pdf
                     Since X represents the solid phase, Y represents .pdf                     Since X represents the solid phase, Y represents .pdf
Since X represents the solid phase, Y represents .pdf
 
Pb^2+ may be present. .pdf
                     Pb^2+ may be present.                            .pdf                     Pb^2+ may be present.                            .pdf
Pb^2+ may be present. .pdf
 
P inversly proportional to 1V so answer is C .pdf
                     P inversly proportional to 1V so answer is C    .pdf                     P inversly proportional to 1V so answer is C    .pdf
P inversly proportional to 1V so answer is C .pdf
 
nutrinos are the smallest part of an atom. NOTE-.pdf
                     nutrinos are the smallest part of an atom. NOTE-.pdf                     nutrinos are the smallest part of an atom. NOTE-.pdf
nutrinos are the smallest part of an atom. NOTE-.pdf
 
Molecular solids are held together in single chai.pdf
                     Molecular solids are held together in single chai.pdf                     Molecular solids are held together in single chai.pdf
Molecular solids are held together in single chai.pdf
 
Liquid crystals (LCs) are a state of matter that .pdf
                     Liquid crystals (LCs) are a state of matter that .pdf                     Liquid crystals (LCs) are a state of matter that .pdf
Liquid crystals (LCs) are a state of matter that .pdf
 
interstellar medium (gas) Solution .pdf
                     interstellar medium (gas) Solution           .pdf                     interstellar medium (gas) Solution           .pdf
interstellar medium (gas) Solution .pdf
 
Hhyd = Hcrystallization + Hsolv Enthalpy of Solv.pdf
                     Hhyd = Hcrystallization + Hsolv  Enthalpy of Solv.pdf                     Hhyd = Hcrystallization + Hsolv  Enthalpy of Solv.pdf
Hhyd = Hcrystallization + Hsolv Enthalpy of Solv.pdf
 
The answer is (b) the condensation of steam to liiquid water.The e.pdf
The answer is (b) the condensation of steam to liiquid water.The e.pdfThe answer is (b) the condensation of steam to liiquid water.The e.pdf
The answer is (b) the condensation of steam to liiquid water.The e.pdf
 
XML Extensiable Markup LanguageHTML Hypertext Markup LanguageD.pdf
XML Extensiable Markup LanguageHTML Hypertext Markup LanguageD.pdfXML Extensiable Markup LanguageHTML Hypertext Markup LanguageD.pdf
XML Extensiable Markup LanguageHTML Hypertext Markup LanguageD.pdf
 
The Data recovery is of two types …One method is by using a softwa.pdf
The Data recovery is of two types …One method is by using a softwa.pdfThe Data recovery is of two types …One method is by using a softwa.pdf
The Data recovery is of two types …One method is by using a softwa.pdf
 
Thanks anon101. D is correctSolutionThanks anon101. D is corre.pdf
Thanks anon101. D is correctSolutionThanks anon101. D is corre.pdfThanks anon101. D is correctSolutionThanks anon101. D is corre.pdf
Thanks anon101. D is correctSolutionThanks anon101. D is corre.pdf
 
StudentData.javaimport java.util.Scanner; public class Student.pdf
StudentData.javaimport java.util.Scanner; public class Student.pdfStudentData.javaimport java.util.Scanner; public class Student.pdf
StudentData.javaimport java.util.Scanner; public class Student.pdf
 
Reverse EngineeringReverse engineering is also a back engineering .pdf
Reverse EngineeringReverse engineering is also a back engineering .pdfReverse EngineeringReverse engineering is also a back engineering .pdf
Reverse EngineeringReverse engineering is also a back engineering .pdf
 
Quantum mechanics predicts the existence of what are usually called .pdf
Quantum mechanics predicts the existence of what are usually called .pdfQuantum mechanics predicts the existence of what are usually called .pdf
Quantum mechanics predicts the existence of what are usually called .pdf
 
Program Educational Objectives • To create competencies and opportun.pdf
Program Educational Objectives • To create competencies and opportun.pdfProgram Educational Objectives • To create competencies and opportun.pdf
Program Educational Objectives • To create competencies and opportun.pdf
 
P2O5 removes H2O from Alcohol to form Alkene O of Alcohol gives it.pdf
P2O5 removes H2O from Alcohol to form Alkene O of Alcohol gives it.pdfP2O5 removes H2O from Alcohol to form Alkene O of Alcohol gives it.pdf
P2O5 removes H2O from Alcohol to form Alkene O of Alcohol gives it.pdf
 
cant understand a thing .pdf
                     cant understand a thing                          .pdf                     cant understand a thing                          .pdf
cant understand a thing .pdf
 

Recently uploaded

Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
AnaAcapella
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 

Recently uploaded (20)

On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
Introduction to TechSoup’s Digital Marketing Services and Use Cases
Introduction to TechSoup’s Digital Marketing  Services and Use CasesIntroduction to TechSoup’s Digital Marketing  Services and Use Cases
Introduction to TechSoup’s Digital Marketing Services and Use Cases
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
PANDITA RAMABAI- Indian political thought GENDER.pptx
PANDITA RAMABAI- Indian political thought GENDER.pptxPANDITA RAMABAI- Indian political thought GENDER.pptx
PANDITA RAMABAI- Indian political thought GENDER.pptx
 
Tatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsTatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf arts
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 

Hi,I have modified the Point.java file as per your requirement.P.pdf

  • 1. Hi, I have modified the Point.java file as per your requirement. Point.java public class Point { double x, y; public Point() { x = 0; y = 0; } public Point(double x, double y) { this.x = x; this.y = y; } public double getX() { return x; } public double getY() { return y; } public double getRadius() { return Math.sqrt(x * x + y * y); } public double getAngle() { return Math.atan2(y, x); } } import org.junit.*; import static org.junit.Assert.*; public class PointTest { private static final double TOLERANCE = 1E-12; @Test public void testNoArg() { Point p = new Point(); assertEquals(0, p.getX(), TOLERANCE); assertEquals(0, p.getY(), TOLERANCE); assertEquals(0, p.getRadius(), TOLERANCE); assertEquals(0, p.getAngle(), TOLERANCE); } @Test public void testXY() {
  • 2. Point p = new Point(3, 4); assertEquals(3, p.getX(), TOLERANCE); assertEquals(4, p.getY(), TOLERANCE); assertEquals(5, p.getRadius(), TOLERANCE); assertEquals(0.9272952180016122, p.getAngle(), TOLERANCE); } } Solution Hi, I have modified the Point.java file as per your requirement. Point.java public class Point { double x, y; public Point() { x = 0; y = 0; } public Point(double x, double y) { this.x = x; this.y = y; } public double getX() { return x; } public double getY() { return y; } public double getRadius() { return Math.sqrt(x * x + y * y); } public double getAngle() { return Math.atan2(y, x); } } import org.junit.*; import static org.junit.Assert.*; public class PointTest { private static final double TOLERANCE = 1E-12; @Test public void testNoArg()
  • 3. { Point p = new Point(); assertEquals(0, p.getX(), TOLERANCE); assertEquals(0, p.getY(), TOLERANCE); assertEquals(0, p.getRadius(), TOLERANCE); assertEquals(0, p.getAngle(), TOLERANCE); } @Test public void testXY() { Point p = new Point(3, 4); assertEquals(3, p.getX(), TOLERANCE); assertEquals(4, p.getY(), TOLERANCE); assertEquals(5, p.getRadius(), TOLERANCE); assertEquals(0.9272952180016122, p.getAngle(), TOLERANCE); } }