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 Calculator{ | |
static int add(int a, int b) => a + b; | |
static int subtract(int a,int b) => b-a; | |
static int multiply(int a,int b)=> a*b; | |
static double divide(int a,int b){ | |
if(b == 0) throw Exception('Cannot divide by zero'); | |
return a/b; |
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
//Is the String Odd (return false) or Even (return true) | |
bool oddOrEven (String txt){ | |
if(txt.isEmpty){throw Exception('input cannot be empty');} | |
RegExp pattern = RegExp(r'^[a-zA-Z]+$'); | |
if(!pattern.hasMatch(txt)){ throw Exception('input should contain letters a-z or A-z');} | |
// if(txt.length %2 == 0) {return true;} return false; , Enhanced to --> | |
return txt.length.isEven; | |
} | |
//Largest Swap (return true if new number less then input or equal it else false) |
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
import 'dart:io'; | |
void main(){ | |
var email = stdin.readLineSync()!; | |
//pattern: Starts with letter, number, special characters _ . + % - (not range so put - at the end or at the start ) | |
// @letters, numbers, . (. to enable multi-level domains) | |
// dot at least 2 letters and stops matching after it | |
RegExp emailPattern = RegExp(r'^[\w.+%-]+@[a-zA-Z0-9.]+\.[a-zA-Z]{2,}$'); | |
print(emailPattern.hasMatch(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
import 'dart:io'; | |
void main(){ | |
//taking the square size from the user | |
print("Enter an Integer: "); | |
var x = int.parse(stdin.readLineSync()!); | |
Game(x); //calling to the function Game to draw the game board | |
} |
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(){ | |
Map page = { //three different parts so map | |
//Part One | |
"header": { | |
"top": { //looks different so map | |
"title": "Company Logo", | |
"nav" : ["Home", "About","Products" , "Contact US"], | |
} , |
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
//image url:https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjOf_9T3L5DzbKhNmNyU95iLlsR573orcbZGQNH9luh1JsQIonMJXTgBZ6d0gF3FIqWzhAW5J4SppoXU6N-yWA80SCrKwM4NqKcw9AwAYYnk8dDS_ovsrKyzS9uM-zTHwfsBH4Nnyuup2YyDbWULlAqmSxHUzZNMmPa5apXghc1z8ECK1CW6cLUai6K/s1200/45b720f598d98b5be44039af1d140f20%20(1).jpg | |
void main() { | |
print ("My cart\n"); | |
var x = [ | |
{ | |
"name": "Polo Shirt For Men", | |
"color": "color-Red", | |
"price": 30, | |
"quantity": 1, | |
}, |