Question: Youmamelabjava ( 2 5 pts ) main method calls each of the test methods in the correct order. ( 5 pts ) testConstructors ( 5

Youmamelabjava (25 pts) main method calls each of the test methods in the correct order. (5 pts) testConstructors (5 pts) testGetNumPoints (5 pts) testGetSlope (5 pts) testGetDistance 5 pts) Movie java (50 pts) Has private instance variables for and y coordinates. (Spts) Has private static variable for number of points. (5 pts) Default constructor calls init Points with correct arguments. (5 pts) Two-argument constructor calls init Points with correct arguments. (5 pts) initPoints (5 pts) Accessors for x and y coordinates. 15 pts) Static accessor for number of points (5 pts) getSlope (5 pts) getDistance (5 pts) toString 15 pts) Instructions Start NetBeans. Create a r new Implement Point project called Lab9 with a main class called YournameLab with your name. Create a Java class file for a Point class. class. Add two private instance variables of type double to represent an x-coordinate and a y coordinate. Write an accessor for each of the private instance variables. Write a default constructor that sets both coordinates to sto zero. Write a two-argument constructor that sets the coordinates to the two doubles provided as parameters. Write a method called toString that constructs a String representation of the Point object. For example, if the x-coordinate is 3.2 and the y-coordinate is 4.5, the toString method should return (3.2,4.5). Test the constructors in the main class. Create a Point object using the default constructor. Display the String value returned by the toString method. Create a second Point object using the two-argument constructor. Display the String value returned by the tostring method for the second point. The output should look something like this: Testing default constructor The point is (0.0,0.0) Testing two-argument constructor The point is (3.5,8.1) Add a static variable and a static method to the Point class. Add a private static variable of type int called numPoints to the Point class to keep track of the number of Point objects created. Initialize it to zero. Write a private non-static method called init Point that takes two double arguments, uses these to initialize the private instance variables, and increments numPoints. Rewrite the two constructors to use init Point to initialize the instance variables to the appropriate values. Write a public static method called getNumPoints that returns the value of numPoints. Test the static variable and static method in the main class. Before the constructor tests, call the getNumPoints method and display the result. Do this again after the constructor tests. The output should look some something like this: Testing getNumPoints method The number of points created is 0 Testing getNumPoints method The number of points created is 2 Add more static methods to the Point class and test them. Write a public static method called getSlope that takes two Point objects as arguments and returns the slope of the line between the two points using the following formula: Add code to the main function to o test the getSlope method. The output should look something like this: Testing getSlope method The slope of the line from (2.0.10) to 14.0,2.0) is 0.5 Write a public static method called getDistance that takes two Point objects as arguments and retums the distance between the two points using the following formula: Add code to the main function to test the getDistance method. The output should look something like this: Testing getDistance method The slope of the line from (0.0,0.0) to (3.0,4.0) is 5.0 Write static methods int the main class to break the program into subtasks, Write a private static void method called testGetNumPoints that performs the test on the getNumPoints method. Replace both tests in the main method with calls to testGetNumPoints. Write a private static void method called testConstructors that performs the tests on the constructors, arid replace those tests with a call to testConstructors in the main method. Write private static void methods called testGetSlope and testGetDistance that perform the tests on getSlope and getDistance and replace those tests in the main method. Malike sure to re-run the program after each step to make sure that the output is the same.

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 Programming Questions!