Skip to content

Instantly share code, notes, and snippets.

@suragch
suragch / encapsulation.cpp
Last active April 29, 2022 01:51
encapsulation
// https://www.youtube.com/watch?v=wN0x9eZLix4
#include <iostream>
#include <regex>
using namespace std;
class AbstractEmployee
{
// Returns true if got promotion
@suragch
suragch / tic-tac-toe.c
Last active April 28, 2022 02:39
Tic-tac-toe
#include <stdio.h>
#define SIZE 15
void printBoard(char board[SIZE][SIZE])
{
printf(" ");
for (int i = 0; i < SIZE; i++) {
printf("%d ", (i + 1) % 10);
}
@suragch
suragch / main.dart
Last active April 18, 2022 03:09
Changing UI
import 'package:flutter/material.dart';
import 'dart:async';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@suragch
suragch / main.dart
Last active April 11, 2022 03:24
Exam prep
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
@suragch
suragch / main.dart
Created February 15, 2022 02:54
Flutter computer and text
import 'package:flutter/material.dart';
void main() {
runApp(MyAmazingApp());
}
class MyAmazingApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
@suragch
suragch / main.dart
Created December 20, 2021 05:07
Stopping a DartPad app
import 'package:flutter/material.dart';
import 'dart:async';
void main() {
runApp(MyApp());
runDart();
}
Timer? myTimer;
@suragch
suragch / password.dart
Created November 18, 2021 01:51
Password
class Password {
Password(String password)
: assert(password.length > 8),
_password = password;
String _password;
set value(String newPassword) {
if (_isTooShort(newPassword)) {
throw Exception('Too short!!!');
@suragch
suragch / linked_list.dart
Last active October 14, 2021 04:36
Queues
import 'package:class_coding/queue.dart';
import 'package:test/test.dart';
void main() {
group('List Queue:', () {
test('isEmpty works', () {
final myQueue = MyQueue<int>();
expect(myQueue.isEmpty, true);
myQueue.enqueue(1);
expect(myQueue.isEmpty, false);
@suragch
suragch / main.dart
Created October 6, 2021 05:59
homework
void main() {
const number = 3;
if (number == 0) {
print('zero');
} else if (number == 1) {
print('one');
}
// if 0 then print 'zero'
// if 1 then print 'one'
@suragch
suragch / main.dart
Last active October 7, 2021 06:57
linked list
void main() {
popExample();
removeLastExample();
removeAfterExample();
}
void popExample() {
var list = LinkedList<int>();
list.push(3);
list.push(2);