-
Notifications
You must be signed in to change notification settings - Fork 0
/
ContactsContact.java
47 lines (32 loc) · 1.11 KB
/
ContactsContact.java
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
package a2;
//Name: Rían Adamian
//Student ID: 260712101
//Purpose: This is the abstract class that provides the template for ContactsAcquaintance,
//ContactsBusiness, and ContactsFriend. I choose to use an abstract class as an inheritance model because
//I know a Contact will never be instantiated that isn't a Acquaintance, Business, or Friend.
abstract public class ContactsContact {
//The attributes for this class are those shared by all types of contacts.
private String name;
private String phoneNo;
//Constructor
public ContactsContact(String name, String phoneNo) {
this.name = name;
this.phoneNo = phoneNo;
}
//Public setter functions that can be called by all types of contacts.
public void setName(String name) {
this.name = name;
}
public void setPhoneNumber(String phoneNo) {
this.phoneNo = phoneNo;
}
//...And the respective getter functions.
public String getName() {
return this.name;
}
public String getPhoneNumber() {
return this.phoneNo;
}
//Abstract method that will return a string of all the contact's fields appended.
abstract public String info();
}