-
-
Save uncoded-ro/7f9014068ce415a35d3182aea7648046 to your computer and use it in GitHub Desktop.
This file contains 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
package ro.virtualcampus.person; | |
import java.io.*; | |
public class Persoana { | |
protected static BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); | |
protected static int nrPersoane = 0; | |
protected String nume; | |
protected int varsta; | |
public Persoana() { | |
nrPersoane++; | |
this.nume = "necunoscut"; | |
this.varsta = 0; | |
} | |
public Persoana(int varsta) { | |
this(); | |
this.varsta = varsta; | |
} | |
public Persoana(String nume, int varsta) { | |
nrPersoane++; | |
this.nume = nume; | |
this.varsta = varsta; | |
} | |
public Persoana(String obj) throws IOException { | |
nrPersoane++; | |
System.out.println("Citire date: " + obj); | |
System.out.print("nume: "); | |
this.nume = in.readLine(); | |
System.out.print("varsta: "); | |
this.varsta = Integer.parseInt(in.readLine()); | |
} | |
public static int getNrPersoane() { | |
return nrPersoane; | |
} | |
public void setNume(String nume) { | |
this.nume = nume; | |
} | |
public String getNume() { | |
return nume; | |
} | |
public void setVarsta(int varsta) { | |
this.varsta = varsta; | |
} | |
public int getVarsta() { | |
return varsta; | |
} | |
@Override | |
public String toString() { | |
return "Persoana [nume=" + nume + ", varsta=" + varsta + "]"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment