-
Notifications
You must be signed in to change notification settings - Fork 1
/
Person.java
164 lines (126 loc) · 3.07 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
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
/**
* This class repersent a person.
* it holds the name, and gender of the person
*
* @author Mohammad Mahdi Malmasi
* @version 0.1.0
*/
public class Person
{
/* Feilds */
// the first name of the person
private String firstName;
// the last name of the person
private String lastName;
// the age of the person
private int age;
// the gender of the person
private String gender;
/* Constructor */
/**
* Create a new Person with given details
*
* @param firstName : the first name of person
* @param lastName : the last name of person
* @param age : the age of person
* @param gender : the gender of person
*/
public Person(String firstName, String lastName, int age, String gender)
{
this.firstName = firstName;
this.lastName = lastName;
this.age = age;
this.gender = gender;
}
/* Methods */
// * setter methods *
/**
* set the first name of the person
* @param firstName : the first name of the person
*/
public void setFirstName(String firstName)
{
this.firstName = firstName;
}
/**
* set the last name of the person
* @param lastName : the last name of the person
*/
public void setLastName(String lastName)
{
this.lastName = lastName;
}
/**
* set the age of the person
* @param age : the age of the person
*/
public void setAge(int age)
{
this.age = age;
}
/**
* set the gender of the person
* @param gender : the gender of the person to set
*/
public void setGender(String gender)
{
this.gender = gender;
}
// * getter methods *
/**
* @return the first name of the person
*/
public String getFirstName()
{
return firstName;
}
/**
* @return the last name of the person
*/
public String getLastName()
{
return lastName;
}
/**
* @return the age of the person
*/
public int getAge()
{
return age;
}
/**
* @return the gender of the person
*/
public String getGender()
{
return gender;
}
/**
* This method make a {@code String} of the person fields and their value
*
* @return a string of the person details
*
* @see an example of output:
* @see .Person first name: Mohammad Mahdi, Person last name: Malmasi, Person age: 19, Person gender: male.
*/
@Override
public String toString()
{
return "Person first name: " + firstName + ", "
+
"Person last name: " + lastName + ", "
+
"Person age: " + age + ", "
+
"Person gender: " + gender + ".\n";
}
/**
* This method shows the person details in standarad output (terminal)
*
* @see Person#toString()
*/
public void print()
{
System.out.println(this.toString());
}
}