Skip to content

Instantly share code, notes, and snippets.

@Modoo-Dev
Created October 6, 2023 09:48
Show Gist options
  • Save Modoo-Dev/b7a4d6b00392c8f04c87f4107b39f2cd to your computer and use it in GitHub Desktop.
Save Modoo-Dev/b7a4d6b00392c8f04c87f4107b39f2cd to your computer and use it in GitHub Desktop.
artPractice-class
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