package BankAccount;

# Constructor
sub new {
  my $class = shift; 
  my ($name,$num) = @_;
  my $self = {
     name => $name, 
     accountNo => $num,
     balance => 0.0,
  }; 
  bless($self, $class);
  return $self;
}

# Retrieve name
sub getName {
  my $self = shift;
  return $self->{name};
}

# Retrieve account #
sub getAccountNo {
  my $self = shift;
  return $self->{accountNo};
}

# Retrieve balance
sub getBalance {
  my $self = shift;
  return $self->{balance};
}

# Add to balance
sub deposit {
  my $self = shift;
  my $amnt = shift;
  $self->{balance} += $amnt;
}

# Deduct from balance
sub withdraw {
  my $self = shift;
  my $amnt = shift;
  $self->{balance} -= $amnt;
}

# Print name,#,balance
sub printAccountDetails {
  my $self = shift;
  print "\nAccount holder: $self->{name}\n";
  print "Account number: $self->{accountNo}\n";
  print "Account balance: $self->{balance}\n";   
}

1;




