Skip to content

Instantly share code, notes, and snippets.

@andymuncey
andymuncey / AddSpriteNode.swift
Last active August 29, 2015 14:23
Example Swift code to create a rectangular SKSpriteNode with solid colour
//create node
var rectangleSpriteNode = SKSpriteNode()
//set sprite colour
rectangleSpriteNode.color = UIColor.yellowColor()
//set 100 width by 500 high
rectangleSpriteNode.size = CGSizeMake(100, 50)
//set the position of the node's centre (200 points across, 100 points up)
@andymuncey
andymuncey / Liskov.swift
Last active August 26, 2016 10:10
LiskovPhraseCode
class LiskovPhraseMaker {
//class properties
private var type = "T"
private var subtype = "S"
func modifiedLiskovPhrase() -> String{
return "If \(subtype) is a subtype of \(type), then objects of type \(type) may be replaced with objects of type \(subtype) (i.e., objects of type \(subtype) may substitute objects of type \(type)) without altering any of the desirable properties of that program (correctness, task performed, etc.)"
}
@andymuncey
andymuncey / StructClassBehaviour.swift
Last active October 5, 2020 16:48
Demonstrates pass by reference vs pass by value difference with Swift struct and class
//change this to a struct and verify the change in behaviour
class Number : CustomStringConvertible {
var number: Int
init(_ num: Int) {
number = num
}
public var description : String {
return "\(number)"
@andymuncey
andymuncey / TrueFalseQuiz.java
Last active July 26, 2022 03:57
True False Quiz example
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// Add code to print your name
System.out.println("REPLACE WITH YOUR NAME");
// Add code to print a message with a truth about yourself (try and think of something interesting)