Question: JAVA: package Data; public class VecD{ // Fields // TODO: Add private class fields to store x and y values given in class constructor //
JAVA:
package Data;
public class VecD{
// Fields
// TODO: Add private class fields to store x and y values given in
class constructor
// Constructor
public VecD(int x, int y){
// TODO: Save the constructor parameters into class fields
}
// Methods
public int getX(){
// TODO: Remove my placeholder code below (which is there to prevent an
error) and replace it with returning the value of your private field x
return 0;
}
public int getY(){
// TODO: Remove my placeholder code below (which is there to prevent an
error) and replace it with returning the value of your private field y
return 0;
}
public void setX(int newX){
// TODO: Update the value of x to be the value in newX (Absolute
assignment)
}
public void setY(int newY){
// TODO: Update the value of y to be the value in newY (Absolute
assignment)
}
// make a change to the vector RELATIVE to the previous value.
public void adjustX(int adjustment){
// TODO: Change the previous value of x by adding the adjustment to the
previous value (Relative assignment)
// Backward adjustments can be made by passing a negative number as an
adjustment
}
// make a change to the vector RELATIVE to the previous value.
public void adjustY(int adjustment){
// TODO: Change the previous value of y by adding the adjustment to the
previous value (Relative assignment)
// Backward adjustments can be made by passing a negative number as an
adjustment
}
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
