Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Goodbye.java #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions ch01/Goodbye.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,48 @@
* 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();
}

}