-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCustomer.java
More file actions
82 lines (78 loc) · 1.79 KB
/
Customer.java
File metadata and controls
82 lines (78 loc) · 1.79 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
class Customer
{
//instance data member
private String nric;
private String name;
private Account[] account;
public Customer(String ic, String n)
{
this.setNric(ic);
this.setName(n);
this.account=new Account[2];
}
//instance mutator
public void setNric(String ic)
{
this.nric = ic;
}
public void setName(String n)
{
this.name = n;
}
public void setAccount(Account acc)
{
if(this.account[0] == null)
{
this.account[0] = new Account(acc);
}
else if(this.account[1] == null)
{
this.account[1] = new Account(acc);
}
}
public void setAccount(int accNo, String at, double b, String dc)
{
if(this.account[0] == null)
{
this.account[0] = new Account(accNo, at, b, dc);
}
else if(this.account[1] == null)
{
this.account[1] = new Account(accNo, at, b, dc);
}
}
//instance accessor
public String getNric()
{
return this.nric;
}
public String getName()
{
return this.name;
}
public Account getAccount(int i)
{
return this.account[i];
}
public Account[] getAccount()
{
return this.account;
}
//printer
public String toString()
{
String accInfo = "";
if (account[0] != null || account[1] != null )
{
if (account[0] != null)
{
accInfo = accInfo + account[0].toString();
}
if (account[1] != null)
{
accInfo = accInfo + account[1].toString();
}
}
return(" "+this.getNric()+" "+this.getName()+"\n"+accInfo);
}
}