-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPerson.java
81 lines (67 loc) · 2.19 KB
/
Person.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
import java.util.Arrays;
public class Person {
private String name;
private String nationality;
private String dateOfBirth;
private String[] passport;
private int seatNumber;
public Person(String name, String nationality, String dateofBirth, int seatNumber){
this.name = name;
this.nationality = nationality;
this.dateOfBirth = dateofBirth;
this.seatNumber = seatNumber;
this.passport = new String[3];
}
public String getName() {
return this.name;
}
public String getNationality() {
return this.nationality;
}
public String getdateofBirth() {
return this.dateOfBirth;
}
public int getseatNumber() {
return this.seatNumber;
}
public String[] getpassport() {
return Arrays.copyOf(passport, passport.length);
}
public void setName(String name){
this.name = name;
}
public void setNationality(String nationality) {
this.nationality = nationality;
}
public void setdateofBirth(String dateofBString) {
this.dateOfBirth = dateofBString;
}
public void setSeatNumber(int seatNumber) {
this.seatNumber = seatNumber;
}public void setPassport(){
this.passport = new String[]{name, nationality, dateOfBirth};
}
public Person(Person source) {
this.name = source.name;
this.nationality = source.nationality;
this.dateOfBirth = source.dateOfBirth;
this.seatNumber = source.seatNumber;
this.passport = Arrays.copyOf(source.passport, source.passport.length);
}
public boolean applyPassport(){
int number = (int) (Math.random() * 2);
if (number == 0) {
return true;
} else {
return false;
}
}public void chooseSeat() {
this.seatNumber = (int) Math.random() * 11 + 1;
}public String toString() {
return "Name: " + this.name + ".\n"
+ "Nationality: " + this.nationality + ".\n"
+ "Date of Birth: " + this.dateOfBirth + ".\n"
+ "Seat Number: " + this.seatNumber + ".\n"
+ "Passport: " + Arrays.toString(passport) + ".\n";
}
}