forked from ChrisMayfield/ThinkJavaCode2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPerson.java
More file actions
26 lines (23 loc) · 801 Bytes
/
Copy pathPerson.java
File metadata and controls
26 lines (23 loc) · 801 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// David Anderson
public class Person {
public String firstName; // should probably be private, we will talk about this later!
public String lastName; // should probably be private, we will talk about this later!
public static int numberOfPeople; // should probably be private, we will talk about this later!
public Person(String firstName, String lastName) {
this.firstName = firstName;
this.lastName = lastName;
numberOfPeople++;
}
@Override
public String toString() {
return firstName + " " + lastName;
}
@Override
public boolean equals(Object object){
if (object instanceof Person) {
Person p = (Person) object;
return this.firstName.equals(p.firstName) && this.lastName.equals(p.lastName);
}
else return false;
}
}