Giter Site home page Giter Site logo

tacoparser's Introduction

Taco Parser Kata

An exercise in geolocation, csv parsing, and logging

Kata Overview

Here's what you'll need to do for this Kata:

  1. Clone this repo to your machine
  2. Complete all the TODOs, while adding appropriate log statements along the way. You can find more details below in the Kata Details section:
    1. Start with writing a Unit Test to Test the Parse method
    2. Implement the Parse Method
    3. Use the GeoCoordinate.NetCore NuGet package to calculate distance between two points
  3. Reduce the logging verbosity and rerun

Kata Details

Here's some more details for completing the steps above.

TacoParser

Updating the Parse method in your TacoParser

This method is used to parse a single row from your CSV file as a string and return an ITrackable:

public ITrackable Parse(string line)
{
    // Take your line and use line.Split(',') to split it up into an array of strings, separated by the char ','
    var cells = line.Split(',');

    // If your array.Length is less than 3, something went wrong
    if (cells.Length < 3)
    {
        // Log that and return null
    }

    // grab the latitude from your array at index 0
    // grab the longitude from your array at index 1
    // grab the name from your array at index 2

    // Your going to need to parse your string as a `double`
    // which is similar to parsing a string as an `int`

    // You'll need to create a TacoBell class
    // that conforms to ITrackable

    // Then, you'll need an instance of the TacoBell class
    // With the name and point set correctly

    // Then, return the instance of your TacoBell class
    // Since it conforms to ITrackable
}

Program

You now have your Parse method working properly. Now, let's get into our Program file in our Main static method.

static void Main(string[] args)
{
    // DON'T FORGET TO LOG YOUR STEPS
    // Grab the path from the name of your file

    // use File.ReadAllLines(path) to grab all the lines from your csv file
    // Log and error if you get 0 lines and a warning if you get 1 line

    // Create a new instance of your TacoParser class
    // Grab an IEnumerable of locations using the Select command: var locations = lines.Select(parser.Parse);

    // Now, here's the new code

    // Create two `ITrackable` variables with initial values of `null`. These will be used to store your two taco bells that are the furthest from each other.
    // Create a `double` variable to store the distance

    // Include the Geolocation toolbox, so you can compare locations: `using GeoCoordinatePortable;`
    // Do a loop for your locations to grab each location as the origin (perhaps: `locA`)
    // Create a new corA Coordinate with your locA's lat and long

    // Now, do another loop on the locations with the scope of your first loop, so you can grab the "destination" location (perhaps: `locB`)
    // Create a new Coordinate with your locB's lat and long
    // Now, compare the two using `.GetDistanceTo()`, which returns a double
    // If the distance is greater than the currently saved distance, update the distance and the two `ITrackable` variables you set above

    // Once you've looped through everything, you've found the two Taco Bells furthest away from each other.
}

tacoparser's People

Contributors

mvdoyle avatar jcrowe91 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.