-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRegistrationSystem.java
More file actions
60 lines (60 loc) · 1.41 KB
/
Copy pathRegistrationSystem.java
File metadata and controls
60 lines (60 loc) · 1.41 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import java.util.*;
public class RegistrationSystem
{
private Map<String, Student> students;
public RegistrationSystem()
{
this.students = new HashMap<>();
}
public void registerStudent(Student student)
{
this.students.put(student.getId(), student);
}
public Student getStudent(String id)
{
return this.students.get(id);
}
public void printAllStudents()
{
for (Student student : this.students.values())
{
System.out.println(student);
}
}
public static void main(String[] args)
{
RegistrationSystem srs = new RegistrationSystem();
Student s1 = new Student("1", "Swarna");
Student s2 = new Student("2", "Subbu");
srs.registerStudent(s1);
srs.registerStudent(s2);
System.out.println("All:");
srs.printAllStudents();
}
}
class Student
{
private String id;
private String name;
public Student(String id, String name)
{
this.id = id;
this.name = name;
}
public String getId()
{
return this.id;
}
public String getName()
{
return this.name;
}
@Override
public String toString()
{
return "Student{" +
"id='" + id + '\'' +
", name='" + name + '\'' +
'}';
}
}