-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathPerson.java
More file actions
42 lines (33 loc) · 773 Bytes
/
Person.java
File metadata and controls
42 lines (33 loc) · 773 Bytes
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
public class Person{
private String myName ; // name of the person
private int myAge; // person's age
private String myGender; // "M" for male, "F" for female
// constructor
public Person(String name, int age, String gender){
myName = name;
myAge = age;
myGender = gender;
}
public String getName(){
return myName;
}
public int getAge(){
return myAge;
}
public String getGender(){
return myGender;
}
public void setName(String name){
myName = name;
}
public void setAge(int age){
myAge = age;
}
public void setGender(String gender){
myGender = gender;
}
public String toString(){
return myName + ", age: " + myAge + ", gender: " +
myGender;
}
}