class Client{ private String nom; private String prenom; private Long tel; Client(String nom , String prenom, Long tel){ this.nom=nom; this.prenom=prenom; this.tel=tel; } public String toString(){ return("nom:"+this.nom+" et le prenom:"+this.prenom+" et le telephone:"+this.tel); } String getNom(){ return nom; } String getPrenom(){ return prenom; } Long getTel(){ return tel; } void setNom(String ch){ this.nom=ch; } void setPre(String ch){ this.prenom=ch; } void setTel(Long t){ this.tel=t; } public Boolean equals(Client c){ return c !=null && c.nom.equals(this.nom) && c.prenom.equals(this.prenom) && c.tel.equals(this.tel); } public static void main(String [] args){ Client c=new Client("sahar","mess",99836678l); Client clt=new Client("sahar","mess",99836678l); System.out.println(c.equals(clt)); System.out.println(c); } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter