-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathPerson.java
More file actions
47 lines (39 loc) · 929 Bytes
/
Person.java
File metadata and controls
47 lines (39 loc) · 929 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
43
44
45
46
47
public class Person
{
//Coding this will be an exercise for the students participating in the lesson; incomplete code fragments will be used to initially demonstrate the concepts.
//As this is a simple program, there isn't any comments within the body - the method and variable names are intended to be self-explanatory.
private String firstName;
private String lastName;
private int age;
public Person(String theirFirstName, String theirLastName, int theirAge)
{
firstName = theirFirstName;
lastName = theirLastName;
age = theirAge;
}
public int getAge()
{
return age;
}
public String getFirstName()
{
return firstName;
}
public String getLastName()
{
return lastName;
}
public String getName()
{
String fullName = firstName + " " + lastName;
return fullName;
}
public void increaseAge()
{
age++;
}
public void increaseAge(int ageIncrement)
{
age += ageIncrement;
}
}