Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Foundation
- class Car{
- var topSpeed = 200
- func drive(){
- print("Driving at \(topSpeed)")
- }
- }
- let myRide = Car()
- class FutureCar : Car{ //inherited car class
- override func drive(){ //override is used for modyfying anything from the superclass Car
- super.drive() //super is used to access and get the superclass
- print("Driving at (after boosting) \(topSpeed + 50)")
- }
- func fly(){
- print("Flying")
- }
- }
- let myFutureRide = FutureCar()
- print(myFutureRide.topSpeed)
- print(myFutureRide.drive())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement