-
-
Save Modoo-Dev/b7a4d6b00392c8f04c87f4107b39f2cd to your computer and use it in GitHub Desktop.
artPractice-class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BankAccount { | |
String accountNumber; | |
String ownerName; | |
double balance; | |
BankAccount(this.accountNumber, this.ownerName, this.balance); | |
void deposit(double amount) { | |
balance += amount; | |
} | |
bool withdraw(double amount) { | |
if (balance >= amount) { | |
balance -= amount; | |
return true; | |
} else { | |
return false; | |
} | |
} | |
double getBalance() { | |
return balance; | |
} | |
void displayAccountInfo() { | |
print('계좌번호: $accountNumber'); | |
print('예금주: $ownerName'); | |
print('잔액: $balance'); | |
} | |
} | |
void main() { | |
var account = BankAccount('123-45-6789', '김희성', 1000.0); | |
account.deposit(500.0); | |
account.displayAccountInfo(); | |
bool success = account.withdraw(300.0); | |
if (success) { | |
print('인출성공'); | |
} else { | |
print('금액부족'); | |
} | |
account.displayAccountInfo(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment