-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTuto1Q1.java
More file actions
56 lines (46 loc) · 1.38 KB
/
Copy pathTuto1Q1.java
File metadata and controls
56 lines (46 loc) · 1.38 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
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package Week1;
/**
*
* @author szeyu
*/
class Telephone{
private String areaCode;
private String number;
private static int numberOfTelephoneObject;
public Telephone(String areaCode, String number){
this.areaCode = areaCode;
this.number = number;
}
public String getAreaCode() {
return areaCode;
}
public void setAreaCode(String areaCode) {
this.areaCode = areaCode;
}
public String getNumber() {
return number;
}
public void setNumber(String number) {
this.number = number;
}
public String makeFullNumber(){
return areaCode + "-" + number;
}
}
public class Tuto1Q1 {
public static void main(String[] args) {
Telephone[] telephones = new Telephone[5];
telephones[0] = new Telephone("03","79676300");
telephones[1] = new Telephone("03","79676301");
telephones[2] = new Telephone("03","79676302");
telephones[3] = new Telephone("03","79676303");
telephones[4] = new Telephone("03","79676304");
for(Telephone telephone : telephones){
System.out.println(telephone.makeFullNumber());
}
}
}