BankAccount Example - PowerPoint PPT Presentation

1 / 26
About This Presentation
Title:

BankAccount Example

Description:

xnattapong_at_hotmail.com. account. 1. BankAccount - balance : double. BankAccount(initBalance:double) ... open account with balance = ' cust.getAccount ... – PowerPoint PPT presentation

Number of Views:46
Avg rating:3.0/5.0
Slides: 27
Provided by: siam4
Category:

less

Transcript and Presenter's Notes

Title: BankAccount Example


1
BankAccount Example
  • Nattapong Songneam
  • http//www.siam2dev.com
  • xnattapong_at_hotmail.com

2
Class Diagram with Multiple Classes
Customer
BankAccount
account
- firstName String
- balance double
- lastName String
1
- account BankAccount

BankAccount(initBalancedouble)
getBalance double

Customer(fString, lString)
deposit(amt double)
getFirstName String
withdraw(amt double)
getLastName String
setAccount( acctBankAccount)
getAccount( ) BankAccount
Class Diagram of Customer.java and
BankAccount.java
3
????? Project ????
  • ????????? File
  • ????? New Project
  • ????????? File
  • ????? New Project

4
????? Project ????
  • ????? java
  • ????? java application
  • ?????? Next

5
???????????? BankAccount
????? Project ????
  • Name BankAccount
  • Location C\java_project
  • ?????? finish

6
????? ???????? (New File)
????? Project ????
  • ????????? File
  • ????? New File

7
????? Project ????
????? ???????? (New File)
  • ????? java
  • ????? java class
  • ?????? Next

8
BankAccount2
  • ????? Class Name BankAccount2
  • ??????

9
??????????? Balance
10
????? ????????????? (constructor)
initBalance initial ???????? Balance ???????
11
?????????????????????? (deposit)
12
?????????????????????? (withdraw)
13
Error ????????????
Error ??????????? return
14
???????????
  • /
  • To change this template, choose Tools
    Templates
  • and open the template in the editor.
  • /
  • package bankaccount
  • /
  • _at_author nat
  • /
  • public class BankAccount2
  • private double Balance
  • public BankAccount2()
  • Balance 0.0
  • public BankAccount2(double initBalance)

15
????? object ??? BankAccount2
Overloading constructor method
16
?????????????? Overloading Method
17
???????????????? BankAccount2
18
???????????????
????????? RUN
???????
19
Customer
public class Customer private String
firstName private String lastName private
BankAccount2 account public Customer(String f,
String l) this.firstName f this.lastName
l this.account null public String
getName() return (this.firstName " "
this.lastName) public BankAccount2
getAccount() return this.account public
void setAccount(BankAccount2 acct) this.account
acct
20
  • public static void main(String args)
  • Customer cust new Customer("Joe","Goodman")
  • cust.setAccount(new BankAccount2(3000.0))
  • System.out.println("customer "
    cust.getName()
  • " open account with balance "
  • cust.getAccount().getBalance() "
    baht.")
  • cust.getAccount().deposit(1250.25)
  • System.out.println("customer "
    cust.getName()
  • " deposit 1250.25 baht "
  • " current balance "
  • cust.getAccount().getBalance() "
    baht.")

21
  • GUI graphic user interface

22
GUI graphic user interface
23
???? OK
24
?????????? Exit
25
?????? jButton2
26
(No Transcript)
Write a Comment
User Comments (0)
About PowerShow.com