public class Point class Test private double x

  • Slides: 4
Download presentation

public class Point { class Test private double x; private double y; public Point

public class Point { class Test private double x; private double y; public Point (double x 1, double y 1) { x = x 1; y = y 1; { static void Main() { double x 1, x 2, y 1, y 2, dx, dy; Point point 1 ; Point point 2; x 1 = double. Parse(Console. Read. Line()); y 1 = double. Parse(Console. Read. Line()); point 1 = new Point(x 1, y 1); x 2 = double. Parse(Console. Read. Line()); y 2 = double. Parse(Console. Read. Line()); point 2 = new Point(x 2, y 2); dx = point 2. Get. X() - point 1. Get. X(); dy = point 2. Get. Y() - point 1. Get. Y(); Console. Write. Line("slope is : {0}", dy/dx); } public void Print() { Console. Write. Line(" point: ({0}, {1}) ", x, y); } //Print public double Get. X() { return x; } //Getx public double Get. Y() { return y; } //Get. Y public void Set. Y(double new. Y) { y = new. Y; } //Set. Y y 1 = double. Parse(Console. Read. Line()); point 2. Set. Y(y 1); dx = point 2. Get. X() - point 1. Get. X(); dy = point 2. Get. Y() - point 1. Get. Y(); Console. Write. Line("slope after changing is : {0}", dy / dx); } } }