This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class BankAccount { | |
| String accountNumber; | |
| String accountHolder; | |
| double _balance; | |
| // Constructor | |
| BankAccount(this.accountNumber, this.accountHolder, [double balance = 0.0]) | |
| : _balance = balance; | |
| // Deposit money |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Contact { | |
| String name; | |
| String phoneNumber; | |
| String email; | |
| Contact({required this.name, required this.phoneNumber, required this.email}); | |
| @override | |
| String toString() { | |
| return 'Name: $name, Phone: $phoneNumber, Email: $email'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void main() { | |
| List<String> students = [ | |
| 'Angela', 'john', 'micheal', 'David', 'Destiny', | |
| 'Favour', 'Grace', 'james', 'mark', 'samuel' | |
| ]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class MathUtils { | |
| // Calculate base raised to the given exponent (default is square) | |
| static num power(num base, [num exponent = 2]) { | |
| // Use math.pow from the dart:math library | |
| return base == 0 && exponent == 0 ? 1 : math.pow(base, exponent); | |
| } | |
| // Calculate factorial of a non-negative integer | |
| static int factorial(int n) { | |
| if (n < 0) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Converts Celsius to Fahrenheit: °C × (9/5) + 32 | |
| double celsiusToFahrenheit(double celsius) { | |
| return celsius * (9 / 5) + 32; | |
| } | |
| // Converts Fahrenheit to Celsius: (F - 32) × 5/9 | |
| double fahrenheitToCelsius(double fahrenheit) { | |
| return (fahrenheit - 32) * 5 / 9; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void main() { | |
| int n = 5; | |
| // Pattern 1 | |
| for (int i = 1; i <= n; i++) { | |
| String row = ""; | |
| for (int j = 1; j <= i; j++) { | |
| row += "*"; | |
| } | |
| print(row); |