Created
May 13, 2020 08:37
-
-
Save Devcodpanda/0e13b6f64d9024b487c3d0892c2a063e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | |
} | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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