0001    import Foundation
0002    
0003    /// 🚲 A two-wheeled, human-powered mode of transportation.
0004    public class Bicycle {
0005        /**
0006        Frame and construction style.
0007    
0008        - Road: For streets or trails.
0009        - Touring: For long journeys.
0010        - Cruiser: For casual trips around town.
0011        - Hybrid: For general-purpose transportation.
0012        */
0013        public enum Style
Bicycle.swift:41
    let style: Style
Bicycle.swift:68
    init(style: Style, gearing: Gearing, handlebar: Handlebar, frameSize centimeters: Int) {
{ 0014 case Road, Touring, Cruiser, Hybrid 0015 } 0016 0017 /** 0018 Mechanism for converting pedal power into motion. 0019 0020 - Fixed: A single, fixed gear. 0021 - Freewheel: A variable-speed, disengageable gear. 0022 */ 0023 public enum Gearing
Bicycle.swift:44
    let gearing: Gearing
Bicycle.swift:68
    init(style: Style, gearing: Gearing, handlebar: Handlebar, frameSize centimeters: Int) {
{ 0024 case Fixed 0025 case Freewheel(speeds: Int) 0026 } 0027 0028 /** 0029 Hardware used for steering. 0030 0031 - Riser: A casual handlebar. 0032 - Café: An upright handlebar. 0033 - Drop: A classic handlebar. 0034 - Bullhorn: A powerful handlebar. 0035 */ 0036 enum Handlebar
Bicycle.swift:47
    let handlebar: Handlebar
Bicycle.swift:68
    init(style: Style, gearing: Gearing, handlebar: Handlebar, frameSize centimeters: Int) {
{ 0037 case Riser, Café, Drop, Bullhorn 0038 } 0039 0040 /// The style of the bicycle. 0041 let style
Bicycle.swift:69
        self.style = style
: Style 0042 0043 /// The gearing of the bicycle. 0044 let gearing
Bicycle.swift:70
        self.gearing = gearing
: Gearing 0045 0046 /// The handlebar of the bicycle. 0047 let handlebar
Bicycle.swift:71
        self.handlebar = handlebar
: Handlebar 0048 0049 /// The size of the frame, in centimeters. 0050 let frameSize
Bicycle.swift:72
        self.frameSize = centimeters
: Int 0051 0052 /// The number of trips travelled by the bicycle. 0053 private(set) var numberOfTrips
Bicycle.swift:74
        numberOfTrips = 0
Bicycle.swift:86
            numberOfTrips += 1
: Int 0054 0055 /// The total distance travelled by the bicycle, in meters. 0056 private(set) var distanceTravelled
Bicycle.swift:75
        distanceTravelled = 0
Bicycle.swift:85
            distanceTravelled += meters
: Double 0057 0058 /** 0059 Initializes a new bicycle with the provided parts and specifications. 0060 0061 - parameter style: The style of the bicycle 0062 - parameter gearing: The gearing of the bicycle 0063 - parameter handlebar: The handlebar of the bicycle 0064 - parameter centimeters: The frame size of the bicycle, in centimeters 0065 0066 - returns: A beautiful, brand-new, custom built just for you. 0067 */ 0068 init(style: Style, gearing: Gearing, handlebar: Handlebar, frameSize centimeters: Int) { 0069 self.style = style 0070 self.gearing = gearing 0071 self.handlebar = handlebar 0072 self.frameSize = centimeters 0073 0074 numberOfTrips = 0 0075 distanceTravelled = 0 0076 } 0077 0078 /** 0079 Take a bike out for a spin. 0080 0081 - parameter meters: The distance to travel in meters. 0082 */ 0083 func travel(distance meters: Double) { 0084 if meters > 0.0 { 0085 distanceTravelled += meters 0086 numberOfTrips += 1 0087 } 0088 } 0089 } 0090