-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConstructorDemoClass.java
52 lines (35 loc) · 1.05 KB
/
ConstructorDemoClass.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
public class ConstructorDemoClass
{
private int age = 0;
private double GPA = 0;
private String firstName = "";
///////////////////////////////////////////////////////////////////////
//THIS IS THE CONSTRUCTOR!!!1
public ConstructorDemoClass(int x, double y, String z)
{
age = x;
GPA = y;
firstName = z;
sayHello(); // this calls the PRIVATE "helper" method sayHello()
}
////////////////////////////////////////////////////////////////////////////////
private void sayHello() // this is a PRIVATE "helper" method
{
System.out.println("Hello, " + firstName);
}
//////////////////////////////////////////////////////////////////////////////
public int getAge()
{
return age;
}
//////////////////////////////////////////////////////////////////////////////
public double getGPA()
{
return GPA;
}
//////////////////////////////////////////////////////////////////////////////
public String getFirstName()
{
return firstName;
}
}