-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPerson.java
More file actions
50 lines (46 loc) · 1.66 KB
/
Person.java
File metadata and controls
50 lines (46 loc) · 1.66 KB
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
41
42
43
44
45
46
47
48
49
50
package module2.oop.inheritance;
/**
* Person
*/
public class Person {
private String name;
private String address;
private String phoneNumber;
private String emailAddress;
/**
* Construct a new <code>Person</code> object
*
* @param name The <code>Person</code>'s name (ex: "John Egbert")
* @param address The <code>Person</code>'s address (ex: "420 Wicked Lane")
* @param phoneNumber The <code>Person</code>'s phone number (ex:
* "123-456-7890")
* @param emailAddress The <code>Person</code>'s email address (ex:
* "sample@address.com")
*/
public Person(String name, String address, String phoneNumber, String emailAddress) {
this.name = name;
this.address = address;
this.phoneNumber = phoneNumber;
this.emailAddress = emailAddress;
}
/** Gets the name of this object's class or sub-class
* @return a class name like <code>"Person"</code> or <code>"Student"</code>*/
public String getClassName() {
return this.getClass().getSimpleName();
}
/** @return an appropriate label for the person's type/role
* such as <code>Person</code> or <code>Student</code> */
public String getTitle() {
return this.getClassName();
}
/** Print out all of the person's data */
@Override
public String toString() {
return (
"👤 " + this.getTitle().toUpperCase() + ": " + this.name + "\n"
+ "🏠 Address: " + address + "\n"
+ "📞 Phone: " + phoneNumber + "\n"
+ "✉️ Email: " + emailAddress
);
}
}