Account withdrawal
Rust Classes & methods
impl + &mut self
Flowchart (ISO 5807)
Source code
struct Account {
balance: f64,
}
impl Account {
fn withdraw(&mut self, amount: f64) -> bool {
if amount > self.balance {
println!("Недостатньо коштів");
return false;
}
self.balance -= amount;
true
}
}