Skip to content

Commit a619f8b

Browse files
committed
object and classes and constructors setter and getters
1 parent 6f62632 commit a619f8b

2 files changed

Lines changed: 89 additions & 0 deletions

File tree

src/Account.java

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
public class Account {
2+
private String number;
3+
private double balance;
4+
private String customerName;
5+
private String customerEmailaddress;
6+
private String customerPhonenumber;
7+
8+
public Account(){
9+
System.out.println("Empty Constructor called");
10+
}
11+
public Account(String number,double balance,String customerName,String customerEmailaddress,String customerPhonenumber){
12+
this.number=number;
13+
this.balance=balance;
14+
this.customerName=customerName;
15+
this.customerEmailaddress=customerEmailaddress;
16+
this.customerPhonenumber=customerPhonenumber;
17+
18+
}
19+
20+
public void deposit(double depositAmount){
21+
this.balance+=depositAmount;
22+
System.out.println("Now the available balance is: "+this.balance);
23+
}
24+
public void withdrawl(double withdrawlAmount){
25+
if(this.balance-withdrawlAmount<0){
26+
System.out.println("Only balance available "+this.balance+" only available");
27+
28+
}
29+
else {
30+
this.balance-=withdrawlAmount;
31+
System.out.println("Withdrwal amount processesd "+withdrawlAmount);
32+
}
33+
}
34+
35+
public String getNumber() {
36+
return number;
37+
}
38+
39+
public void setNumber(String number) {
40+
this.number = number;
41+
}
42+
43+
public double getBalance() {
44+
return balance;
45+
}
46+
47+
public void setBalance(double balance) {
48+
this.balance = balance;
49+
}
50+
51+
public String getCustomerName() {
52+
return customerName;
53+
}
54+
55+
public void setCustomerName(String customerName) {
56+
this.customerName = customerName;
57+
}
58+
59+
public String getCustomerEmailaddress() {
60+
return customerEmailaddress;
61+
}
62+
63+
public void setCustomerEmailaddress(String customerEmailaddress) {
64+
this.customerEmailaddress = customerEmailaddress;
65+
}
66+
67+
public String getCustomerPhonenumber() {
68+
return customerPhonenumber;
69+
}
70+
71+
public void setCustomerPhonenumber(String customerPhonenumber) {
72+
this.customerPhonenumber = customerPhonenumber;
73+
}
74+
}

src/AccountMain.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
public class AccountMain {
2+
public static void main(String[] args) {
3+
Account bobsAccount=new Account();
4+
bobsAccount.withdrawl(100);
5+
bobsAccount.deposit(100);
6+
bobsAccount.withdrawl(50);
7+
8+
Account johnAccount=new Account("12345",80.0,"bob brown",
9+
"[email protected]","12348877");
10+
System.out.println(johnAccount.getBalance());
11+
System.out.println(johnAccount.getNumber());
12+
13+
}
14+
15+
}

0 commit comments

Comments
 (0)