-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathDatabase.java
More file actions
43 lines (37 loc) · 885 Bytes
/
Database.java
File metadata and controls
43 lines (37 loc) · 885 Bytes
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
import java.util.ArrayList;
import java.util.Iterator;
/**
* A very simple database of people in a university. This class simply stores
* persons and, at request, lists them on standard output.
*
* Written as a first demo program for BlueJ.
*
* @author Michael Kölling
* @version 1.1, March 2002
*/
public class Database {
private ArrayList<Person> persons;
/**
* Create a new, empty person database.
*/
public Database()
{
persons = new ArrayList<Person>();
}
/**
* Add a person to the database.
*/
public void addPerson(Person p)
{
persons.add(p);
}
/**
* List all the persons currently in the database on standard out.
*/
public void listAll ()
{
for (Iterator i = persons.iterator(); i.hasNext();) {
System.out.println(i.next());
}
}
}