public class Pos
extends java.lang.Object
| Constructor and Description |
|---|
Pos(int r,
int c)
Constructs a position from row r and column c.
|
Pos(Pos p)
Constructs a position from Pos p
|
| Modifier and Type | Method and Description |
|---|---|
int |
distance(Pos p)
Returns the "manhatttan distance" between "this" position and p.
|
boolean |
equals(java.lang.Object o)
Tests for equaltiy of a Pos with an arbitraty object.
|
boolean |
equals(Pos p)
Tests for equality of row/col coordinates between two positions.
|
int |
getCol()
returns the column for this position.
|
int |
getRow()
returns the row for this position.
|
int |
hashCode()
Returns a hashcode for Pos objects that is OK for our Project3 application.
|
static Pos |
read(java.util.Scanner sc)
Reads a new position from scanner sc, e.g.
|
Pos |
sum(Pos p)
Returns a new point whose row is the sum of this's row and p's row, and column likewise.
|
java.lang.String |
toString()
Returns a string representation, e.g.
|
public Pos(int r,
int c)
public Pos(Pos p)
public int getRow()
public int getCol()
public java.lang.String toString()
toString in class java.lang.Objectpublic boolean equals(Pos p)
public boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic int distance(Pos p)
public Pos sum(Pos p)
public static Pos read(java.util.Scanner sc)
public int hashCode()
hashCode in class java.lang.Object