Bicycle

public class Bicycle

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

  • Frame and construction style.

    See more

    Declaration

    Swift

    public enum Style
  • Mechanism for converting pedal power into motion.

    See more

    Declaration

    Swift

    public enum Gearing
  • Hardware used for steering.

    See more

    Declaration

    Swift

    public enum Handlebar
  • The style of the bicycle.

    Declaration

    Swift

    public let style: Style
  • The gearing of the bicycle.

    Declaration

    Swift

    public let gearing: Gearing
  • The handlebar of the bicycle.

    Declaration

    Swift

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

    Declaration

    Swift

    public let frameSize: Int
  • Initializes a new bicycle with the provided parts and specifications.

    Declaration

    Swift

    public 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

    public func travel(distance meters: Double)

    Parameters

    meters

    The distance to travel in meters.

  • Declaration

    Swift

    public var description: String { get }