public class Pies { protected String id = ""; protected String nazwa = ""; protected String kolor = ""; protected int wiek = 0; protected String wlasciciel = ""; Pies(int id,String nazwa,String kolor,int wiek,String imieWlasciciela,String nazwiskoWlasciciela) { this.id = Integer.toString(id); while(this.id.length() != 8) { this.id = "0" + this.id; } this.nazwa = nazwa; this.kolor = kolor; this.wiek = wiek; this.wlasciciel = imieWlasciciela + " " + nazwiskoWlasciciela; } public String toString() { String ret = "-------------------------------\n"; ret += "identyfikator: " + this.id + "\n"; ret += "WLASCICIEL: " + this.wlasciciel + "\n"; ret += "IMIE: " + this.nazwa + "\n"; ret += "masc: " + this.kolor + "\n"; String wiekString = ""; if(wiek > 11) { wiekString += (this.wiek / 12) + " lat(a)"; if(this.wiek % 12 != 0) { wiekString += " i " + (this.wiek % 12) + " miesiecy"; } } else { wiekString += (this.wiek % 12) + " miesiecy"; } ret += "wiek: " + wiekString + "\n"; ret += "-------------------------------\n"; return ret; } }