Skip to content

Homework-1#1

Open
prashant1shukla wants to merge 1 commit intomainfrom
Homework-1
Open

Homework-1#1
prashant1shukla wants to merge 1 commit intomainfrom
Homework-1

Conversation

@prashant1shukla
Copy link
Owner

image

Comment on lines +21 to +29
if (balance >= amount)
{
balance -= amount;
Console.WriteLine($"Withdrawn Rs{amount}. New balance: Rs{balance}");
}
else
{
Console.WriteLine("Error: Insufficient balance.");
}
Copy link

@sanchit203 sanchit203 May 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is correct but what you can do to make it more readable is to always have the negative conditions first.
So you code will look like

if (balance < amount)
{
   // do the needful
}
else
{
    // do the needful
}


public class BankAccount
{
private int balance;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use _ prefix for private fields. So this should be renamed to _balance

@@ -0,0 +1,46 @@
using System;

public class BankAccount

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be a separate file BankAccount.cs which should contain this class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants