Skip to content
View Jokes3311's full-sized avatar
  • ME
  • Jacksonville Florida 32218
  • 20:47 (UTC -12:00)

Block or report Jokes3311

Block user

Prevent this user from interacting with your repositories and sending you notifications. Learn more about blocking users.

You must be logged in to block users.

Please don't include any personal information such as legal names or email addresses. Maximum 100 characters, markdown supported. This note will be visible to only you.
Report abuse

Contact GitHub support about this user’s behavior. Learn more about reporting abuse.

Report abuse
Jokes3311/README.md

{"Hello,Words"}{"Hello,Words"}Here's the pretty-formatted version of the code you provided:

class PaymentCard:
    def __init__(self, card_number, card_holder, expiration_date, cvv):
        self.card_number = card_number
        self.card_holder = card_holder
        self.expiration_date = expiration_date
        self.cvv = cvv
        self.balance = 5000  # Set initial balance to $5000

    def add_funds(self, amount):
        try:
            amount = float(amount)
            if amount <= 0:
                raise ValueError("Amount must be a positive number")
            self.balance += amount
            print(f"Added {amount} to card balance. New balance: {self.balance}")
        except ValueError as e:
            print(f"Error: {e}")

    def make_payment(self, amount):
        try:
            amount = float(amount)
            if amount <= 0:
                raise ValueError("Amount must be a positive number")
            if self.balance >= amount:
                self.balance -= amount
                print(f"Payment of {amount} successful. Remaining balance: {self.balance}")
            else:
                print("Insufficient funds. Payment declined.")
        except ValueError as e:
            print(f"Error: {e}")


# Creating an instance of PaymentCard
my_card = PaymentCard("1234 5678 9012 3456", "John Doe", "12/25", "123")

# Displaying the balance for 3 days
for _ in range(3):
    print(f"Current balance: {my_card.balance}")

Changes I made:

  • Indented the last print statement as it was falling outside the for loop.
  • add_funds method was not adding the amount to the existing balance. Instead, it was replacing the balance with the new amount. Changed the logic to correctly add (+=) the amount.
  • Changed the Spanish text "Saldo actual: " to English "Current balance: " for consistency

Popular repositories Loading

  1. Jokes3311 Jokes3311 Public

    Config files for my GitHub profile.