Skip to content

Commit 53a2848

Browse files
victory
1 parent 6052c8b commit 53a2848

4 files changed

Lines changed: 40 additions & 15 deletions

File tree

a.out

2.67 MB
Binary file not shown.

b.out

2.67 MB
Binary file not shown.

bank_account.hpp

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,43 @@ class BankAccount {
88
double balance;
99

1010
public:
11-
// Constructor
12-
BankAccount(){
13-
// TODO: Implement the constructor
11+
// Default constructor
12+
BankAccount() {
13+
accountNumber = "";
14+
accountHolderName = "";
15+
balance = 0;
1416
}
1517

16-
BankAccount(const std::string& accNumber, const std::string& accHolder, double initialBalance){
17-
// TODO: Implement the constructor
18+
// Custom constructor
19+
BankAccount(const std::string& accNumber, const std::string& accHolder, double initialBalance) {
20+
accountNumber = accNumber;
21+
accountHolderName = accHolder;
22+
balance = initialBalance;
1823
}
1924

2025
// Deposit method
2126
void Deposit(double amount) {
22-
// TODO: Implement the Deposit method
27+
if (amount > 0) {
28+
balance += amount;
29+
}
2330
}
2431

2532
// Withdraw method
2633
void Withdraw(double amount) {
27-
// TODO: Implement the Deposit method
34+
if (amount > 0 && amount <= balance) {
35+
balance -= amount;
36+
}
2837
}
2938

30-
// Display account information
39+
// Display account info
3140
void DisplayAccountInfo() {
32-
// TODO: Implement the DisplayAccountInfo method
41+
std::cout << "Account Holder: " << accountHolderName << "\n";
42+
std::cout << "Account Number: " << accountNumber << "\n";
43+
std::cout << "Balance: $" << balance << "\n";
3344
}
3445

46+
// Get balance
3547
double GetBalance() const {
36-
std::cout << "Test" << std::endl;
3748
return balance;
3849
}
3950
};
40-
41-

factorial.hpp

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,25 @@
11
#define CATCH_CONFIG_MAIN
22

3-
// Function to calculate factorial using multiple threads
3+
#include <stdexcept>
4+
45
long calculateFactorial(int n) {
5-
long result = 0;
6-
//TODO: Implement the function to calculate factorial of n
6+
if (n < 0) {
7+
throw std::invalid_argument("Factorial of negative number not defined");
8+
}
9+
10+
long result = 1;
11+
12+
for (int x = 1; x <= n; x++) {
13+
result = result * x;
14+
}
715

816
return result;
917
}
18+
19+
20+
21+
22+
23+
24+
25+

0 commit comments

Comments
 (0)