Skip to content

Instantly share code, notes, and snippets.

@Devcodpanda
Created May 13, 2020 08:37
Show Gist options
  • Save Devcodpanda/0e13b6f64d9024b487c3d0892c2a063e to your computer and use it in GitHub Desktop.
Save Devcodpanda/0e13b6f64d9024b487c3d0892c2a063e to your computer and use it in GitHub Desktop.
class Classroom {
public static void main(String[] args){
// references to a new instance of the Wilder class
Wilder joe = new Wilder("Joe", false);
Wilder bill = new Wilder("Bill", true);
System.out.println(joe.whoAmI());
System.out.println(bill.whoAmI());
}
}
class Wilder {
// attributes
private String firstname;
private boolean aware;
// constructeurs
public Wilder(String firstname, boolean aware){
this.firstname = firstname;
this.aware = aware;
}
// getters
public String getFirstname(){
return this.firstname;
}
public boolean isAware(){
return this.aware;
}
// setters
public void setFirstname(String firstname){
this.firstname = firstname;
}
public void setAware(boolean aware){
this.aware = aware;
}
// method
public String whoAmI(){
if(this.aware==true){
return "Je m'appelle " + this.getFirstname() + " et je suis aware!";
} else {
return " Je m'appelle " + this.getFirstname() + " et je ne suis pas aware!";
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment