I've a assignment question,
A point on two dimensional plane can be represented by two numbers: an x coordinate and y coordinate. Eg (4,5). The sum of two point can be defined as a new point whose x coordinate is the sum of the x coordinates of two points similarly y coordinate is the sum of the y coordinates of two points.
and i've create the following code,
class Dimensions {
int x_coordinate;
int y_coordinate;
public void print(){
System.out.println ("(x,y) = " + "(" + x_coordinate + "," + y_coordinate + ")");
}
public Dimensions (int i, int j){
x_coordinate = i;
y_coordinate = j;
}
}
class abc {
public static void main (String args[]){
Dimensions first = new Dimensions (5,10);
Dimensions second = new Dimensions (10,10);
first.print();
second.print();
}
}
it is working fine and printing two x-coordinated and two y-coordinates but how can i add two points of x-coodinate and two points of y-coordinate ??
i want to sum it in class Dimensions and return the value in main