-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathday2.java
More file actions
70 lines (44 loc) · 1.21 KB
/
day2.java
File metadata and controls
70 lines (44 loc) · 1.21 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
61
62
63
64
65
66
67
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main{
public static void main(String args[]){
Contact c1 = new Contact("alex", 23123123, "c1@gmail.com");
Contact c2 = new Contact("Takumi", 8686, "Akina@gmail.com");
ContactManager.add(c1);
ContactManager.add(c2);
ContactManager.showAll();
}
}
class Contact{
private String name;
private int number;
private String email;
public Contact(String name, int number, String email){
this.name = name;
this.number = number;
this.email = email;
}
//getter and setter
public String getName(){return name;}
public void setName(String name){this.name = name;}
public int getNumber(){return number;}
public void setNumber(int number){this.number = number;}
public String getEmail(){return email;}
public void setEmail(String email){this.email = email;}
@Override
public String toString(){
return "name-> " + name + " number-> " + number + " email-> " + email;
}
}
class ContactManager{
private static List<Contact> contacts = new ArrayList<>();
public static void add(Contact con){
contacts.add(con);
}
public static void showAll(){
for(Contact i : contacts){
System.out.println(i);
}
}
}