Skip to content

Instantly share code, notes, and snippets.

@mikamboo
Forked from anonymous/gist:5684491
Last active December 17, 2015 22:49
Show Gist options
  • Save mikamboo/5684516 to your computer and use it in GitHub Desktop.
Save mikamboo/5684516 to your computer and use it in GitHub Desktop.
Java create a class : constructors & get / set methods
/**
* Classe Personne
* Décrit un objet personne par son nom et son age
*
*/
public class Personne {
private String name;
private int age;
/*
* Dans ce constructeur on initialise seulement le nom
*/
public Personne(String nom_personne){
name = nom_personne;
}
/*
* Dans ce constructeur on initialise nom et age
*/
public Personne(String nom_personne, int age_personne){
name = nom_personne;
age = age_personne;
}
public String getName(){
return name;
}
public void setName(String name){
this.name = name;
}
public int getAge(){
return age;
}
public void setName(int age){
this.age = age;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment