Skip to content

Instantly share code, notes, and snippets.

View polymorphism.cpp
#include <iostream>
#include <regex>
using namespace std;
class AbstractEmployee
{
// Returns true if got promotion
virtual bool RequestPromotion() = 0;
virtual void Work() = 0;
@suragch
suragch / inheritance_example.cpp
Created May 6, 2022
Inheritance example - passing objects in constructors
View inheritance_example.cpp
#include <iostream>
using namespace std;
class Pet{
protected:
string Name;
string Breed;
int Age;
Pet(string name, string breed, int age)
@suragch
suragch / justtext.c
Created May 4, 2022
Formatting a text file in C
View justtext.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
FILE* getTextFromFile(char filename[]) {
FILE* ptr;
ptr = fopen("data.csv", "r");
if (NULL == ptr) {
printf("file can't be opened \n");
}
@suragch
suragch / get_it.dart
Last active May 2, 2022
Three buttons, change icon (with GetIt and manager class)
View get_it.dart
import 'package:final_exam/home_screen/home_screen_manager.dart';
import 'package:get_it/get_it.dart';
final getIt = GetIt.instance;
void setupGetIt() {
getIt.registerLazySingleton(() => HomeScreenManager());
}
@suragch
suragch / home_screen.dart
Created May 2, 2022
Three buttons, change icon (with manager class)
View home_screen.dart
import 'package:flutter/material.dart';
import 'home_screen_manager.dart';
class HomeScreen extends StatefulWidget {
const HomeScreen({Key? key}) : super(key: key);
@override
State<HomeScreen> createState() => _HomeScreenState();
}
@suragch
suragch / home_screen.dart
Created May 2, 2022
Three buttons, change icon
View home_screen.dart
import 'package:flutter/material.dart';
class HomeScreen extends StatefulWidget {
const HomeScreen({Key? key}) : super(key: key);
@override
State<HomeScreen> createState() => _HomeScreenState();
}
class _HomeScreenState extends State<HomeScreen> {
View inheritance.cpp
#include <iostream>
#include <regex>
using namespace std;
class AbstractEmployee
{
// Returns true if got promotion
virtual bool RequestPromotion() = 0;
};
@suragch
suragch / abstraction_example.cpp
Created Apr 22, 2022
High and low level navigation
View abstraction_example.cpp
#include <iostream>
using namespace std;
class Point {
int x;
int y;
public:
Point(int X, int Y) {
x = X;
View encapsulation.cpp
// https://www.youtube.com/watch?v=wN0x9eZLix4
#include <iostream>
#include <regex>
using namespace std;
class AbstractEmployee
{
// Returns true if got promotion
View tic-tac-toe.c
#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);
}