Question: Consider the following class Point which represents a point in Cartesian coordinate system. The class has two instance variables x and y which represent its

Consider the following class Point which represents a point in Cartesian coordinate system. The class has two instance variables x and y which represent its position along the x-axis and y-axis. The constructor of the class initializes the x and y of the point with the specific value init; the method move() moves the point as specified by its parameter amount.

Using the implementation of the class Point information and write its specification. The specification of the class includes the specification of its methods. Each method specification contains the method's name, signature, informal English description, precondition, postcondition (return), throws list.

class Point{

private int x;

private int y;

public Point(int init){

x = init;

y = init;

}

public void move(int amount){

if(amount < 0 )

throws new IllegalArgumentException();

else if(amount = 0)

return;

else{

x += amount;

y += amount;

}

}

}

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