Skip to content

Instantly share code, notes, and snippets.

@nataliepo
Created September 2, 2014 00:59
Show Gist options
  • Save nataliepo/8832a66594af4082b93c to your computer and use it in GitHub Desktop.
Save nataliepo/8832a66594af4082b93c to your computer and use it in GitHub Desktop.
Vehicle-Car
//
// CarFactory.swift
// test1
//
// Created by Alex Meckes on 9/1/14.
// Copyright (c) 2014 Alex Meckes. All rights reserved.
//
import Foundation
class Vehicle {
var hasFourWheelDrive = false
var numberOfWheels = 0
var numberOfPassengers = 0
init() {
println("[Vehicle::init]")
}
}
class Car : Vehicle {
var name = ""
var color = ""
var horsepower = 0
var automaticOption = false
init() {
super.init()
println("[Car::init]")
// leave all of this class's variables as default,
// but, set the parent's number of wheels.
numberOfWheels = 4
}
func soupUpHorsepower (var valueToIncrease: Int) -> Int {
horsepower += valueToIncrease
return horsepower
}
}
func mullOverCarOptions() {
println("I think I want a Corvette.")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment