Can you tell me if this is right please import java.lang.reflect.AnnotatedArrayT
ID: 3674726 • Letter: C
Question
Can you tell me if this is right please
import java.lang.reflect.AnnotatedArrayType;
/**
* The class <b>Point</b> is a simple helper class that stares a 2 dimentional element on a grid
*
* @author Guy-Vincent Jourdan, University of Ottawa
*/
public class Point {
public int dot, row, col;
// ADD YOUR INSTANCE VARIABLES HERE
/**
* Constructor
*
* @param x
* the x coordinate
* @param y
* the y coordinate
*/
public Point(int x, int y){
// REPLACE THE BODY OF THIS METHOD WITH YOUR OWN IMPLEMENTATION
this.row= x;
this.col= y;
}
/**
* Getter method for the attribute x.
*
* @return the value of the attribute x
*/
public int getX(){
// REPLACE THE BODY OF THIS METHOD WITH YOUR OWN IMPLEMENTATION
return this.row;
}
/**
* Getter method for the attribute y.
*
* @return the value of the attribute y
*/
public int getY(){
// REPLACE THE BODY OF THIS METHOD WITH YOUR OWN IMPLEMENTATION
return this.col;
}
/**
* Setter for x and y.
* @param x
* the x coordinate
* @param y
* the y coordinate
*/
public void reset(int x, int y){
// REPLACE THE BODY OF THIS METHOD WITH YOUR OWN IMPLEMENTATION
}
}
Explanation / Answer
/**This Point class has constructor to set row and column vlaue of a Point. The Point class also has methods to set row and column values and get methods to return row and column values*/
//Point.java
public class Point
{
//private members
public int dot, row, col;
//Constructor that sets the x and y values of Point class
public Point(int x, int y)
{
this.row= x;
this.col= y;
}
//Set row value
public void setX(int x){
row=x;
}
//Set col value
public void setY(int y){
col=y;
}
//Returns row value
public int getX(){
return this.row;
}
//Returns col value
public int getY()
{
return this.col;
}
//Reset row and col to x and y values
public void reset(int x, int y)
{
row=x;
col=y;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.