-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPerson.java
More file actions
40 lines (32 loc) · 749 Bytes
/
Person.java
File metadata and controls
40 lines (32 loc) · 749 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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
public class Person {
//Instance variables
//
private String name;
//Constructors
//
public Person() {//Default Constructor
this.name = "no name yet";
}//Person
public Person(String aName) {//Parameterized Constructor
this.setName(aName);
}//Person <<String>>
//Accessors
//
public String getName() {
return this.name();
}//getName
//Mutators
//
public void setName(String aName) {
this.name = aName;
}//setName
//Other Methods
//
public boolean equals(Person aPerson) {
//Check for a Null exception
return aPerson != null && this.name.equals(aPerson.getName());
}//equals
public String toString() {//Return the name as String
return this.name;
}//toString
}//Person