Завершите создание конструкторов Location с меткой FIXME в классе Location.JAVA

Программисты JAVA общаются здесь
Ответить Пред. темаСлед. тема
Гость
 Завершите создание конструкторов Location с меткой FIXME в классе Location.

Сообщение Гость »


Complete the Location constructors labelled FIXME in the Location class.

Код: Выделить всё

package comp1110.ass1; import java.util.Objects; /**  * This class encodes a certain cartesian coordinate system (row, column). We call this row-major order.  * For example, in the grid below the letter 'd' is at (1,0) Row 1, column 0. Row and Column values may be any  * positive or negative integer.  *   * 0 1 2  * 0 a b c  * 1 d e f  * 2 g h i  */ public class Location implements Comparable {     /**      * The Location's row-coordinate      */     private int row;     /**      * The Location's column-coordinate      */     private int column;     /**      * A default "out-of-bounds" coordinate      */     static final int OUT = -1;     /**      * Create a Location that is not on the board      */     public Location() {         this.row = OUT;         this.column = OUT;     }     /**      * Create a new location, given an x- and y-coordinate.      *       * Note that we can access the fields of the object under construction      * using the `this` keyword.      * This constructor needs to be able to handle any integer input.      *      * @param row    the x-coordinate      * @param column the y-coordinate      */     public Location(int row, int column) {         // FIXME: Task 1     }     /**      * Given a two-character string representing a pair of (row, column) coordinates on the board,      * construct the corresponding Location. Recall that the two character represent the row and column      * coordinates of the Location respectively, so the string "01" corresponds to the location      * (0,1).      * This string representation will only contain coordinates on the game board, between values 0 to 2 inclusive.      *      * @param coordinates a String representing a pair of (row,column) coordinates.      */     public Location(String coordinates) {         // FIXME: Task 1     }     public int getRow() {         return this.row;     }     public int getColumn() {         return column;     }     public void setRow(int row) {         this.row = row;     }     public void setColumn(int column) {         this.column = column;     }     /**      * Returns whether this Location is on the Colour Catch board or not.      *       * Remember that you can access the x and y coordinates of this instance of Location using      * the `this` keyword. (Check out the getter and setter methods above)      *      * @return True if this Location is on the board, False otherwise.      */     public boolean isOnBoard() {         return this.row >= 0 && this.row = 0 && this.column 

Источник: [url]https://stackoverflow.com/questions/78131916/complete-the-location-constructors-labelled-fixme-in-the-location-class[/url]
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «JAVA»