-
Notifications
You must be signed in to change notification settings - Fork 0
/
Person.java
46 lines (37 loc) · 853 Bytes
/
Person.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
public class Person {
//instance variables
private static int personCount;//used to assign an id to ppl
private int id;
private String name;
//constructors
public Person(){
personCount+=1;
id=-1;
name="N/A";
}
public Person(String legalName){
personCount+=1;
id=100+personCount;
name=legalName;
}
//toString
public String toString(){
return "name: " + name + " id: " + id
+ " (Person count: " + personCount + ")";
}
//accessor methods
public int getId(){
return id;
}
public String getName(){
return name;
}
public int getCount(){
return personCount;
}
//modifier method
public void reset(int idNum, String legalName){
id=idNum;
name=legalName;
}
}