|
| 1 | +using System; |
| 2 | +using System.Collections.Generic; |
| 3 | +using System.Text; |
| 4 | + |
| 5 | +namespace NetArchTest.TestStructure.Metrics |
| 6 | +{ |
| 7 | + // This class was generated by GPT-4 Turbo :D |
| 8 | + public class ClassLarge |
| 9 | + { |
| 10 | + // Fields |
| 11 | + private string owner; |
| 12 | + private double balance; |
| 13 | + private double interestRate; |
| 14 | + |
| 15 | + // Constructors |
| 16 | + public ClassLarge() |
| 17 | + { |
| 18 | + owner = "Unknown"; |
| 19 | + balance = 0.0; |
| 20 | + interestRate = 0.0; |
| 21 | + } |
| 22 | + |
| 23 | + public ClassLarge(string owner, double balance, double interestRate) |
| 24 | + { |
| 25 | + this.owner = owner; |
| 26 | + this.balance = balance; |
| 27 | + this.interestRate = interestRate; |
| 28 | + } |
| 29 | + |
| 30 | + // Methods |
| 31 | + public void Deposit(double amount) |
| 32 | + { |
| 33 | + // Check if the amount is positive |
| 34 | + if (amount > 0) |
| 35 | + { |
| 36 | + // Add the amount to the balance |
| 37 | + balance += amount; |
| 38 | + // Print a confirmation message |
| 39 | + Console.WriteLine("You have deposited {0:C} to your account.", amount); |
| 40 | + } |
| 41 | + else |
| 42 | + { |
| 43 | + // Print an error message |
| 44 | + Console.WriteLine("Invalid amount. Please enter a positive number."); |
| 45 | + } |
| 46 | + } |
| 47 | + |
| 48 | + public void Withdraw(double amount) |
| 49 | + { |
| 50 | + // Check if the amount is positive |
| 51 | + if (amount > 0) |
| 52 | + { |
| 53 | + // Check if the amount is less than or equal to the balance |
| 54 | + if (amount <= balance) |
| 55 | + { |
| 56 | + // Subtract the amount from the balance |
| 57 | + balance -= amount; |
| 58 | + // Print a confirmation message |
| 59 | + Console.WriteLine("You have withdrawn {0:C} from your account.", amount); |
| 60 | + } |
| 61 | + else |
| 62 | + { |
| 63 | + // Print an error message |
| 64 | + Console.WriteLine("Insufficient funds. You cannot withdraw more than your balance."); |
| 65 | + } |
| 66 | + } |
| 67 | + else |
| 68 | + { |
| 69 | + // Print an error message |
| 70 | + Console.WriteLine("Invalid amount. Please enter a positive number."); |
| 71 | + } |
| 72 | + } |
| 73 | + |
| 74 | + public void Transfer(double amount, ClassLarge other) |
| 75 | + { |
| 76 | + // Check if the other account is not null |
| 77 | + if (other != null) |
| 78 | + { |
| 79 | + // Check if the amount is positive |
| 80 | + if (amount > 0) |
| 81 | + { |
| 82 | + // Check if the amount is less than or equal to the balance |
| 83 | + if (amount <= balance) |
| 84 | + { |
| 85 | + // Subtract the amount from the balance |
| 86 | + balance -= amount; |
| 87 | + // Add the amount to the other account's balance |
| 88 | + other.balance += amount; |
| 89 | + // Print a confirmation message |
| 90 | + Console.WriteLine("You have transferred {0:C} to {1}'s account.", amount, other.owner); |
| 91 | + } |
| 92 | + else |
| 93 | + { |
| 94 | + // Print an error message |
| 95 | + Console.WriteLine("Insufficient funds. You cannot transfer more than your balance."); |
| 96 | + } |
| 97 | + } |
| 98 | + else |
| 99 | + { |
| 100 | + // Print an error message |
| 101 | + Console.WriteLine("Invalid amount. Please enter a positive number."); |
| 102 | + } |
| 103 | + } |
| 104 | + else |
| 105 | + { |
| 106 | + // Print an error message |
| 107 | + Console.WriteLine("Invalid account. Please enter a valid account."); |
| 108 | + } |
| 109 | + } |
| 110 | + |
| 111 | + public void ApplyInterest() |
| 112 | + { |
| 113 | + // Calculate the interest amount |
| 114 | + double interest = balance * interestRate / 100; |
| 115 | + // Add the interest amount to the balance |
| 116 | + balance += interest; |
| 117 | + // Print a confirmation message |
| 118 | + Console.WriteLine("You have earned {0:C} in interest.", interest); |
| 119 | + } |
| 120 | + |
| 121 | + // Override ToString method |
| 122 | + public override string ToString() |
| 123 | + { |
| 124 | + return $"Owner: {owner}, Balance: {balance:C}, Interest Rate: {interestRate}%"; |
| 125 | + } |
| 126 | + } |
| 127 | +} |
0 commit comments