Bicycle

class Bicycle

🚲 A two-wheeled, human-powered mode of transportation.

  • Frame and construction style.

    See more

    Declaration

    Swift

    enum Style
  • Mechanism for converting pedal power into motion.

    See more

    Declaration

    Swift

    enum Gearing
  • Hardware used for steering.

    See more

    Declaration

    Swift

    enum Handlebar
  • The style of the bicycle.

    Declaration

    Swift

    let style: Style
  • The gearing of the bicycle.

    Declaration

    Swift

    let gearing: Gearing
  • The handlebar of the bicycle.

    Declaration

    Swift

    let handlebar: Handlebar
  • The size of the frame, in centimeters.

    Declaration

    Swift

    let frameSize: Int
  • The number of trips travelled by the bicycle.

    Declaration

    Swift

    private(set) var numberOfTrips: Int
  • The total distance travelled by the bicycle, in meters.

    Declaration

    Swift

    private(set) var distanceTravelled: Double
  • Initializes a new bicycle with the provided parts and specifications.

    Declaration

    Swift

    init(style: Style,
         gearing: Gearing,
         handlebar: Handlebar,
         frameSize centimeters: Int)

    Parameters

    style

    The style of the bicycle

    gearing

    The gearing of the bicycle

    handlebar

    The handlebar of the bicycle

    frameSize

    The frame size of the bicycle, in centimeters

    Return Value

    A beautiful, brand-new bicycle, custom-built just for you.

  • Take a bike out for a spin.

    Precondition

    meters must be greater than 0.

    Declaration

    Swift

    func travel(distance meters: Double)

    Parameters

    meters

    The distance to travel in meters.

  • Declaration

    Swift

    public var description: String { get }