Person.java
public class Person {
private String name;
private int age;
private Gender gender;
private int homeland;
//public static final int FEMALE = 0;
//public static final int MALE = 1;
//public static final int UNKNOWN = 2;
public static final int TONGA = 0;
public static final int SAMOA = 1;
public static final int TAHITI = 2;
public static final int JAPAN = 3;
public static final int KOREA = 4;
public static final int MALAYSIA = 5;
public static final int CHINA = 6;
public static final int FIJI = 8;
public static final int USA = 9;
public static final int CANADA = 10;
public static final int PHILIPPINES = 11;
public static final int BRAZIL = 12;
public Person() {
name = "Untel";
age = 19;
gender = Gender.UNKNOWN;
homeland = UNKNOWN;
}
public void setName(String s) {
name = s;
}
public void setAge(int a) {
age = a;
}
public void setGender(int g) {
gender = g;
}
public void setHomeland(int h) {
homeland = h;
}
}
Vertex.java
public class Vertex {
public int x;
public int y;
/**
* this is the
* default constructor
*/
public Vertex() {
x = 0;
y = 0;
}
/**
* this constructor takes two parameters.
* @param xx this is the X coordinate
* @param yy this is the Y coordinate
*/
public Vertex(int xx, int yy) {
x = xx;
y = yy;
}
/**
* this is the "copy constructor"
* @param other the existing Vertex you want to "clone"
*/
public Vertex(Vertex other) {
x = other.x;
y = other.y;
}
/**
* this method lets you put the vertex at a new location
* @param xx this is the X coordinate
* @param yy this is the Y coordinate
*/
public void set(int xx, int yy) {
x = xx;
y = yy;
}
public void offset(int dx, int dy) {
x += dx;
y += dy;
}
@Override
public String toString() {
return "(" + x + "," + y + ")";
}
/**
* compares two vertex objects
* @param o the other vertex to compare with this one
* @return true if they x's and y's are equal, false otherwise.
*/
@Override
public boolean equals(Object o) {
if (o instanceof Vertex) {
Vertex other = (Vertex)o;
if (this.x == other.x && this.y == other.y) {
return true;
} else {
return false;
}
} else {
return false;
}
}
}
Gender.java
public enum Gender {
FEMALE,
MALE,
UNKNOWN
}
Kaipo.java
public class Kaipo {
public static void main(String[] args) {
Person p1 = new Person();
//just made a Canadian person. Oops!
p1.setHomeland(Person.CHINA + Person.KOREA);
}
}