Skip to content

Instantly share code, notes, and snippets.

View 22ln's full-sized avatar
💭
...

Rana Emam 22ln

💭
...
  • 09:30 (UTC +03:00)
View GitHub Profile
@22ln
22ln / main.dart
Created August 10, 2025 10:58
Task6
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;
@22ln
22ln / main.dart
Created August 6, 2025 13:08
Task5
//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)
@22ln
22ln / main.dart
Created August 2, 2025 22:24
Task4
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));
@22ln
22ln / main.dart
Created July 27, 2025 04:43
Task3
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
}
@22ln
22ln / main.dart
Created July 23, 2025 10:56
task2
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"],
} ,
@22ln
22ln / main.dart
Created July 20, 2025 09:01
Task1
//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,
},