Question: Youmamelabjava ( 2 5 pts ) main method calls each of the test methods in the correct order. ( 5 pts ) testConstructors ( 5
Youmamelabjava pts main method calls each of the test methods in the correct order. pts testConstructors pts testGetNumPoints pts testGetSlope pts testGetDistance pts Movie java pts Has private instance variables for and y coordinates. Spts Has private static variable for number of points. pts Default constructor calls init Points with correct arguments. pts Twoargument constructor calls init Points with correct arguments. pts initPoints pts Accessors for x and y coordinates. pts Static accessor for number of points pts getSlope pts getDistance pts toString pts Instructions Start NetBeans. Create a r new Implement Point project called Lab 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 xcoordinate 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 twoargument 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 xcoordinate is and the ycoordinate is the toString method should return 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 twoargument 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 Testing twoargument constructor The point is 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 nonstatic 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 Testing getNumPoints method The number of points created is 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 to is 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 to is 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 rerun 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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
