Skip to content

Instantly share code, notes, and snippets.

View mitulmanish's full-sized avatar
🍏
🛩🇪🇪

mitul_manish mitulmanish

🍏
🛩🇪🇪
View GitHub Profile
@mitulmanish
mitulmanish / Main.java
Created April 25, 2016 10:19
Composite Design Patern
package com.company;
import java.util.List;
import java.util.ArrayList;
interface Graphic {
//Prints the graphic.
public void print();
}
@mitulmanish
mitulmanish / Main.java
Created April 25, 2016 13:34
Example of Composite Design pattern
package com.company;
import java.util.ArrayList;
interface Shape{
void draw(String fillColor);
}
class Square implements Shape{
@mitulmanish
mitulmanish / Main.java
Created April 25, 2016 15:28
Decorator Pattern in Java
package com.company;
interface Coffee{
Double getCost();
String getIngredients();
}
class SimpleCoffee implements Coffee {
@Override
@mitulmanish
mitulmanish / CurrentWeatherViewController.swift
Created April 29, 2016 10:13
Using CLLocationManager to fetch current location
//
// CurrentWeatherViewController.swift
// betterment
//
// Created by Mitul Manish on 29/04/2016.
// Copyright © 2016 Mitul Manish. All rights reserved.
//
//
// ViewController.swift
@mitulmanish
mitulmanish / CoreDataInverseRelationSaveExample.swift
Created May 19, 2016 07:59
Saving for inverse relationship in Core Data
class CoreDataInverseRelationSaveExample {
@IBAction func saveNewSkill(sender: UIBarButtonItem) {
print("finding User")
let fetchRequest = NSFetchRequest(entityName: "Person")
fetchRequest.predicate = NSPredicate(format: "%K == %@", "userID", CURRENT_USER)
//3
@mitulmanish
mitulmanish / main.java
Created June 18, 2016 12:40
Bridge Pattern implement in Java
interface Switch {
void turnOn();
}
interface Appliance {
void run();
}
class TV implements Appliance {
@mitulmanish
mitulmanish / FactoryPattern.java
Created June 18, 2016 13:31
Factory Pattern implemented in Java
package com.company;
enum Country
{
UnitedStates, Spain, Greece, UK
}
interface Currency {
String symbol();
String code();
@mitulmanish
mitulmanish / Command.java
Created June 18, 2016 15:15
Command Pattern implemented in Java
interface DoorCommand {
String execute();
}
class Door {
String doorName;
public Door(String doorName) {
@mitulmanish
mitulmanish / Builder.java
Created June 19, 2016 11:00
Builder Pattern implemented in Java
import java.util.ArrayList;
import java.util.List;
interface Item {
String name();
Packing packing();
int price();
}
interface Packing {
@mitulmanish
mitulmanish / TwoDimensionalArray.swift
Created July 6, 2016 07:03
Iterating over 2D array in Swift(with indices)
let twoDimArr: [[Int]] = [[0, 0, 1], [1, 0, 1]]
for (i,row) in twoDimArr.enumerate() {
for (j, cell) in row.enumerate() {
print("m[\(i),\(j)] = \(cell)")
print("**************")
}
}