import Foundation // Used to import certain features
// Class declaration
class Question {
// Properties
let questionText : String
let answer : Bool
// Init function that will provide some values for when an object is created
// More specifically, this is a designated initializer
// It REQUIRES the following arguments when creating an object
init(text : String, correctAnswer : Bool) {
questionText = text
answer = correctAnswer
}
// For custom inputs, use the convenience initializer
// Usually, the init() is kept empty and parameterless
// needs the self.init() to set the default values!
convenience init(customerChosenColor : String) {
self.init()
color = customerChosenColor
}
}
// To create an obj:
var question = Question(text: String, correctAnswer: Bool)
// If a SelfDrivingCar inherits from the Car class:
class SelfDrivingCar : Car {
}
// Overriding a particular method in an inherited class
class Animal {
func breathe() {
}
}
class Fish : Animal {
// Override the breath function
override func breathe() {
// perform everthing your inherited class does
super.breathe()
// plus do some extra stuff unique to this class
}
}