Convert this Python code into Ruby. class BankAccount: def __init__(self, aBalance=0): self._currentBalance = aBalance; def deposit(self, amount): self._currentBalance =self._currentBalance+amount def withdraw(self, amount): self._currentBalance = self._currentBalance-amount def getCurrentBalance(self): return self._currentBalance anAccount = BankAccount(5) anAccount.withdraw(5) print(anAccount.getCurrentBalance())
Convert this Python code into Ruby. class BankAccount: def __init__(self, aBalance=0): self._currentBalance = aBalance; def deposit(self, amount): self._currentBalance =self._currentBalance+amount def withdraw(self, amount): self._currentBalance = self._currentBalance-amount def getCurrentBalance(self): return self._currentBalance anAccount = BankAccount(5) anAccount.withdraw(5) print(anAccount.getCurrentBalance())
Chapter4: More Object Concepts
Section: Chapter Questions
Problem 5RQ
Related questions
Question
Convert this Python code into Ruby.
class BankAccount: def __init__(self, aBalance=0): self._currentBalance = aBalance; def deposit(self, amount): self._currentBalance =self._currentBalance+amount def withdraw(self, amount): self._currentBalance = self._currentBalance-amount def getCurrentBalance(self): return self._currentBalance anAccount = BankAccount(5) anAccount.withdraw(5) print(anAccount.getCurrentBalance())
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps with 1 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT