Bicycle

public class Bicycle

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

  • Frame and construction style.

    • Road: For streets or trails.
    • Touring: For long journeys.
    • Cruiser: For casual trips around town.
    • Hybrid: For general-purpose transportation.
    See more

    Declaration

    Swift

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

    • Fixed: A single, fixed gear.
    • Freewheel: A variable-speed, disengageable gear.
    See more

    Declaration

    Swift

    public enum Gearing
  • Hardware used for steering.

    • Riser: A casual handlebar.
    • Café: An upright handlebar.
    • Drop: A classic handlebar.
    • Bullhorn: A powerful handlebar.
    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
  • The number of trips travelled by the bicycle.

    Declaration

    Swift

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

    Declaration

    Swift

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

    • Parameters:

      • style: The style of the bicycle
      • gearing: The gearing of the bicycle
      • handlebar: The handlebar of the bicycle
      • centimeters: The frame size of the bicycle, in centimeters

    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

    centimeters

    The frame size of the bicycle, in centimeters

    Return Value

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

  • Take a bike out for a spin.

    Declaration

    Swift

    public func travel(distance meters: Double)

    Parameters

    meters

    The distance to travel in meters.