GithubHelp home page GithubHelp logo

parkingapp's Introduction

Parking App

Requirements

  • Built through XCode 12

simulator build located in "Sumulator App Bundle" folder

asessment's required function/method

Payment.swift

func processPayment(for amountPaying: Double, for amountDeducting: Double) throws -> String {
        ...
    }

processPayment method takes in 2 parameters, amountPaying which is the amount paid to parking and amountDeducting which is the amount to be deducted from the the amount(amountPaying) payed, it then subtracts the numbers and returns the change/remaining amount in ZAR(rands)

Unit Tests

Testing Payment process

func testPayment() throws {
        
        XCTAssertEqual(try sut.processPayment(for: 50, for: 50), "\(0.0) ZAR", "Test passed, R50.0 - R50.0 is R0.0")
        XCTAssertEqual(try sut.processPayment(for: 50, for: 30), "\(20.0) ZAR", "Tessed passed, R50.0 - R30.0 is R20.0")
        XCTAssertThrowsError(try sut.processPayment(for: 0, for: 10)) // test passes, error thrown when amount paying is Zero and bellow
        XCTAssertThrowsError(try sut.processPayment(for: 30, for: 50))// test passes, error thrown when amount paying is less than the amount duducting
    }

Error handling

PaymentError.swift

enum PaymentError: Error {
    case notEnoughFundsError
    case cannotBeZeroError
    case emptyFieldError
    case invalidValue
}

Mock up data - faking data

MockUpData.swift

func fakeParkedHours() ->  Int {
        minutesParked = parkingMinutesArray[Int.random(in: 0..<(parkingMinutesArray.count - 1))]
        let parkingTime = minutesParked / 60
        return parkingTime
    }

An array subscript from parkingMinutesArray[] is chosen at random, this array contains made up minutes at which the fake vehicle has been parked, results from the fakeParkedHours() ia later used in PayForParkingViewControolerto simulate parked time as to allow a demonstraion of paying for the parking

Additional UI App functionality

PayForParkingViewController

Hour/time of parked is chosen at random and app allows user to pay for parking, the purple circle on the upper right of the shows how long the user has been parked

the image above shows the price to be paid for parking

PaymentSuccessViewController

parkingapp's People

Watchers

Rhulani Ndhlovu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.