import { Component, Input, Output, EventEmitter } from '@angular/core';

@Component({
  selector: 'app-child',
  standalone: true,
  templateUrl: './child.component.html',
})
export class ChildComponent {
  @Input() public balance: number = 0;
  @Output() balanceChange = new EventEmitter<number>();

  public isBroke = false;

  public takeMoney() {
    if (this.balance <= 0) {
      this.isBroke = true;
    } else {
      this.balance -= 50;
      if (this.balance == 0) {
        this.isBroke = true;
      }
      this.balanceChange.emit(this.balance);
    }
  }
}
