Skip to content

Instantly share code, notes, and snippets.

View azmaltech's full-sized avatar

Mohammad Azmal Hossain azmaltech

View GitHub Profile
@azmaltech
azmaltech / TypeLevel - Swift
Last active October 8, 2016 07:46
A bank account method
class BankAccount{
let accountNumber : Int
let rountingCode = 12345678
var blance : Double
class var interestRate : Float{
return 2.0
}
init(number : Int, initialBalance : Double){
@azmaltech
azmaltech / Computed Properties
Created October 8, 2016 05:09
In addition to stored properties, classes, structures, and enumerations can define computed properties, which do not actually store a value. Instead, they provide a getter and an optional setter to retrieve and set other properties and values indirectly.
class Person{
// stored properties
var firstName : String
var lastName : String
// computed property
var fullName : String{
return firstName + " " + lastName // return the computed property
@azmaltech
azmaltech / Inheritance
Created October 7, 2016 20:56
Generally a class can inherit methods, properties and functionalities from another class. Classes can be further categorized in to sub class and super class.
//http://stackoverflow.com/questions/24021093/error-in-swift-class-property-not-initialized-at-super-init-call
//
class SuperClass {
var state : String
var old : Int
var income : Double
func SuperClassInfo(){
print("this is \(state), the state is \(old) years older. and anual incoming is \(income) billion")
}
init(){
@azmaltech
azmaltech / Class - Swift
Last active October 6, 2016 18:58
Classe builds blocks of your program’s code. define properties and methods to add functionality to your classes using exactly the same syntax as for constants, variables, and functions.
import UIKit
// a simple class
class State{
var region = " "
var population = 0
var gdp = 0.0
func stateInfo(){
print("the State Name is \(region),here has more than \(population) milion people and in recent year they earn \(gdp)% GDP")
}
}
@azmaltech
azmaltech / Closure - Swift
Created October 6, 2016 10:45
Closures group code into a self-contained, reusable unit, Functions are a type of closure
var myClosure = { print("this is a simple closure")}
func myClosureFuncton( closureParamiter : ()->() ){
for _ in 1...5{
closureParamiter()
}
}
myClosureFuncton(myClosure)
// more shortly
@azmaltech
azmaltech / Enumeration – Swift
Created October 6, 2016 09:30
An enumeration defines a common type for a group of related values and enables you to work with those values in a type-safe way within your code.
// enumeration of plane seat book
enum PlaneSeat{
case window,middle,aisle,freeSeat
}
/* var select : PlaneSeat
select = .aisle */
var select = PlaneSeat.aisle
switch select{
case .window :
@azmaltech
azmaltech / Optional - Swift
Last active October 6, 2016 07:23
Optional handles the absence of a value. Optionals say either "there is a value" or "there isn't a value at all".
var temperature : Int?
print("Today temperature is \(temperature)")
//prints "Today temperature is nil"
// optional with dictionary
var myDictionary = ["cn":"China","uk":"England","bd":"Bangladesh"]
if var state = myDictionary ["bd"]{
print(state)
}else{
@azmaltech
azmaltech / Azmal Tech's links
Last active October 6, 2016 07:25
Azmal Tech's links
@azmaltech
azmaltech / Structure
Created May 4, 2016 14:39
Structure of Declaring and accessing c 2
#include <stdio.h>
#include <stdlib.h>
#define size 50
struct azmalOne{
char firstName[size];
char lastName[size];
char color[size];
int age;
float height;
float weight;
@azmaltech
azmaltech / Structure
Last active May 4, 2016 14:37
Structure of Declaring and accessing c
#include <stdio.h>
#include <stdlib.h>
#define size 50
struct azmalOne{
char firstName[size];
char lastName[size];
char color[size];
int age;
float height;
float weight;