-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathGoodbye.java
More file actions
49 lines (42 loc) · 1.24 KB
/
Goodbye.java
File metadata and controls
49 lines (42 loc) · 1.24 KB
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
/**
* Example program that demonstrates print vs println.
*/
public class Goodbye {
//Instance variables
private String name, status;
//Static class-wide counter variable.
private static int id = 0;
public Goodbye(String n, String s){
this.name = n;
this.status = s;
id += 1;
}
/**
* Setter and Getter methods for Encapsulation
*/
public void setName(String name){
this.name = name; }
public String getName(){
return this.name;}
public void setStatus(String status){
this.status = status;}
public String getStatus(){
return this.status;}
//Handler method for output
public void getGoodbyeInfo(){
System.out.println("Name: "+getName());
System.out.println("Current Status: "+getStatus());
System.out.println("ID: "+this.id);
}
/**
* Prints a greeting.
*/
public static void main(String[] args) {
System.out.print("Goodbye, "); // note the space
System.out.println("cruel world");
System.out.println("I'm being no longer with you");
//Instantiate a new object of class Goodbye
Goodbye obj1 = new Goodbye("HP-LAT-1946IPV0", "Running");
obj1.getGoodbyeInfo();
}
}