-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAffiliate.java
204 lines (192 loc) · 5.36 KB
/
Affiliate.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
// a. Michael Bertagna
// b. 2353491
// c. [email protected]
// d. CPSC 231-01
// e. MP4: University Database
/** Affiliate.java
* This is a simple Affiliate abstract class
* @author Michael Bertagna
* @author Student ID: 2353491
* @author [email protected]
* CPSC 231-01 - Prof. Stevens
* Assignment MP4: University Database
* @version 1.0
*/
/** The Affiliate abstract class is used as a base class for more specific Affiliates and
* contains basic Affiliate attributes: name, age, address, phone number, and year entered Chapman.
*/
public abstract class Affiliate implements Printable, Comparable<Affiliate>{
/**
* The name of the affiliate.
*/
protected String m_name;
/**
* The age of the affiliate.
*/
protected int m_age;
/**
* The address of the affiliate.
*/
protected String m_address;
/**
* The phone number of the affiliate.
*/
protected String m_phoneNumber;
/**
* The year the affiliate came to Chapman.
*/
protected int m_yearEnteredChapman;
/**
* The default constructor - creates a new Affiliate with name=null,
* age=0, address=null, phoneNumber=null, yearEnteredChapman=0.
*/
public Affiliate(){
m_name=null;
m_age=0;
m_address=null;
m_phoneNumber=null;
m_yearEnteredChapman=0;
}
/**
* The overloaded constructor - creates a new Affiliate with
* specified attributes.
* @param name - String name of Affiliate
* @param age - Int age of Affiliate
* @param address - String address of Affiliate
* @param phoneNumber - String phone number of Affiliate
* @param yearEnteredChapman - int year Affiliate entered Chapman
*/
public Affiliate(String name, int age, String address, String phoneNumber, int yearEnteredChapman){
m_name=name;
m_age=age;
m_address=address;
m_phoneNumber=phoneNumber;
m_yearEnteredChapman=yearEnteredChapman;
}
/**
* The copy constructor - creates a deep copy of an Affiliate
* @param otherAffiliate - Affiliate to copy
*/
public Affiliate(Affiliate otherAffiliate){
m_name=otherAffiliate.m_name;
m_age=otherAffiliate.m_age;
m_address=otherAffiliate.m_address;
m_phoneNumber=otherAffiliate.m_phoneNumber;
m_yearEnteredChapman=otherAffiliate.m_yearEnteredChapman;
}
/**
* Returns name of Affiliate
* @return name as a String
*/
public String getName(){
return m_name;
}
/**
* Returns age of Affiliate
* @return age as an int
*/
public int getAge(){
return m_age;
}
/**
* Returns the address of Affiliate
* @return address as a String
*/
public String getAddress(){
return m_address;
}
/**
* Returns the phone number of Affiliate
* @return phone number as a String
*/
public String getPhoneNumber(){
return m_phoneNumber;
}
/**
* Returns the year the Affiliate entered Chapman as an int
* @return year the Affiliate entered Chapman as an int
*/
public int getYearEnteredChapman(){
return m_yearEnteredChapman;
}
/**
* Sets the name
* @param name - String to set name as
*/
public void setName(String name){
m_name=name;
}
/**
* Sets the age
* @param age - int to set the age as
*/
public void setAge(int age){
m_age=age;
}
/**
* Sets the address
* @param address - String to set address as
*/
public void setAddress(String address){
m_address=address;
}
/**
* Sets the phone number
* @param phoneNumber - String to set the phone number as
*/
public void setPhoneNumber(String phoneNumber){
m_phoneNumber=phoneNumber;
}
/**
* Sets the year the Affiliate entered Chapman
* @param yearEnteredChapman - int to set year Affiliate entered Chapman as
*/
public void setYearEnteredChapman(int yearEnteredChapman){
m_yearEnteredChapman=yearEnteredChapman;
}
/**
* Returns true if two Affiliates equal, else False
* @param otherAffiliate - Affiliate for comparison
* @return boolean: true if equal and false if not equal
*/
public boolean equals(Affiliate otherAffiliate){
return (m_name.equals(otherAffiliate.m_name)&&
m_age==otherAffiliate.m_age&&
m_address.equals(otherAffiliate.m_address)&&
m_phoneNumber.equals(otherAffiliate.m_phoneNumber)&&
m_yearEnteredChapman==otherAffiliate.m_yearEnteredChapman);
}
/**
* Compares two Affiliates based on year came to Chapman (earlier year is greater)
* @param otherAffiliate - Affiliate to compare to
* @return int 1(if greater), -1(if less than), and 0(if equal)
*/
public int compareTo(Affiliate otherAffiliate){
int comparison=0;
if (getYearEnteredChapman()<otherAffiliate.getYearEnteredChapman()){
comparison=1;
}
else if (getYearEnteredChapman()>otherAffiliate.getYearEnteredChapman()){
comparison=-1;
}
else{
comparison=0;
}
return comparison;
}
/**
* Pretty prints attributes
*/
public void print(){
System.out.println("Name: "+m_name+"\nAge: "+m_age+"\nAddress: "+m_address+"\nPhone Number: "
+m_phoneNumber+"\nYear Entered Chapman: "+m_yearEnteredChapman);
}
/**
* Returns a pretty String of attributes for use in writing to files
* @return String of pretty printed attributes
*/
public String filePrint(){
return(m_address+", "+m_age+", "+m_name+", "
+m_phoneNumber+", "+m_yearEnteredChapman);
}
}