Skip to content

Instantly share code, notes, and snippets.

View gayashanbc's full-sized avatar
:octocat:
Nothing is true, everything is permitted...

Gayashan Bombuwala gayashanbc

:octocat:
Nothing is true, everything is permitted...
View GitHub Profile
@gayashanbc
gayashanbc / Subject.hpp
Last active July 22, 2018 18:32
Header file of the Subject class (Observer Pattern in C++)
//
// Created by shan on 4/7/17.
//
#ifndef OBSERVER_PATTERN_SUBJECT_HPP
#define OBSERVER_PATTERN_SUBJECT_HPP
#include "Observer.hpp"
@gayashanbc
gayashanbc / Observer.hpp
Created July 22, 2018 18:36
Header file of the Observer class (Observer Pattern in C++)
//
// Created by shan on 4/7/17.
//
#ifndef OBSERVER_PATTERN_OBSERVER_HPP
#define OBSERVER_PATTERN_OBSERVER_HPP
/**
* Interface for the Observer
*/
@gayashanbc
gayashanbc / WeatherData.hpp
Created July 22, 2018 18:38
Header file of the WeatherData class (Observer Pattern in C++)
//
// Created by shan on 4/7/17.
//
#ifndef OBSERVER_PATTERN_WEATHERDATA_HPP
#define OBSERVER_PATTERN_WEATHERDATA_HPP
#include <vector>
#include <algorithm>
#include <iostream>
@gayashanbc
gayashanbc / WeatherData.cpp
Created July 22, 2018 18:40
Implementation file of the WeatherData class (Observer Pattern in C++)
//
// Created by shan on 4/7/17.
//
#include "WeatherData.hpp"
void WeatherData::registerObserver(Observer *observer) {
observers.push_back(observer);
}
@gayashanbc
gayashanbc / Client.hpp
Created July 22, 2018 18:41
Header file of the Client class (Observer Pattern in C++)
//
// Created by shan on 4/7/17.
//
#ifndef OBSERVER_PATTERN_CLIENT_1_HPP
#define OBSERVER_PATTERN_CLIENT_1_HPP
#include <iostream>
#include "Observer.hpp"
@gayashanbc
gayashanbc / Client.cpp
Created July 22, 2018 18:43
Implementation file of the Client class (Observer Pattern in C++)
//
// Created by shan on 4/7/17.
//
#include "Client.hpp"
void Client::update(float temp, float humidity, float pressure) {
// print the changed values
std::cout << "---Client (" << id << ") Data---\tTemperature: " << temp
<< "\tHumidity: " << humidity
@gayashanbc
gayashanbc / main.cpp
Created July 22, 2018 18:46
Implementation file of the main class (Observer Pattern in C++)
#include <iostream>
#include "WeatherData.hpp"
#include "Client.hpp"
int main() {
WeatherData weatherStation;
Client one(1), two(2), three(3);
float temp, humidity, pressure;
@gayashanbc
gayashanbc / index.html
Created July 22, 2018 18:54
Angular Tutorials in Sinhala | V1 of index.html
<!DOCTYPE html>
<html>
<head>
<title>Hello from AngularJS</title>
</head>
<body>
</body>
@gayashanbc
gayashanbc / index.html
Last active July 22, 2018 18:58
Angular Tutorials in Sinhala | V2 of index.html
<!DOCTYPE html>
<html>
<head>
<title>Hello from AngularJS</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.3/angular.min.js">
</script>
</head>
<body>
@gayashanbc
gayashanbc / index.html
Created July 22, 2018 18:59
Angular Tutorials in Sinhala | V3 of index.html
<!DOCTYPE html>
<html>
<head>
<title>Hello from AngularJS</title>
<script src="angular.min.js"></script>
</head>
<body>
</body>