-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPerson.java
More file actions
50 lines (41 loc) · 1.44 KB
/
Person.java
File metadata and controls
50 lines (41 loc) · 1.44 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
import java.util.ArrayList;
public class Person
{
private Name name;
private Address address;
private ArrayList<Course> courses;
public Person( String first, String last) {
this.name = new Name(first,last);
}
public void setLastName( String name) {
String old = this.name.toString();
String[] x = old.split(" ");
this.name = new Name(x[0],name.toString());
}
public String getLastName() {
String old = this.name.toString();
String[] x = old.split(" ");
return x[1];
}
public String getFirstName() {
String old = this.name.toString();
String[] x = old.split(" ");
return x[0];
}
public String getFullName() { return this.name.toString(); }
public void setAddress(Address address) throws Exception {
String old = address.toString();
String[] x = old.split(" ");
if (x.length <4) { this.address = new Address(x[0],x[1],x[2]); }
else { this.address = new Address(Integer.parseInt(x[0]),x[1],x[2],x[3]);}
}
public Address getAddress() { return this.address; };
public Course[] getCourses() {
Course[] a = null;
return this.courses.toArray(a);
}
public void addCourse( Course course ) {this.courses.add(course);}
public void remove(Course course) {this.courses.remove(course);}
public String toString() { return null; }
public boolean equals(Object o) { return false; }
}