Exemplo n.º 1
0
        public ITrackable Parse(string line)
        {
            if (line == null)
            {
                logger.LogInfo("input was null");
                return(null);
            }
            var cells = line.Split(',');

            if (cells.Length < 3)
            {
                return(null);
            }


            var latitude = double.Parse(cells[0]);

            var longitude = double.Parse(cells[1]);

            var tacoName = (cells[2]);

            TacoBell Coords = new TacoBell(tacoName, latitude, longitude);

            logger.LogInfo($"{latitude} {longitude} {tacoName}");
            return(Coords);
        }
        public ITrackable Parse(string line)
        {
            logger.LogInfo("Begin parsing");

            var cells = line.Split(',');

            if (cells.Length < 3)
            {
                logger.LogError("It was less than 3");
                return(null);
            }

            double Latitude  = double.Parse(cells[0]);
            double Longitude = double.Parse(cells[1]);
            string Name      = cells[2];
            // Do not fail if one record parsing fails, return null
            TacoBell newTacoBell = new TacoBell();

            newTacoBell.Name = cells[2];
            Point pointStorage = new Point();

            pointStorage.Latitude  = Latitude;
            pointStorage.Longitude = Longitude;
            newTacoBell.Location   = pointStorage;

            return(newTacoBell); // TODO Implement
        }
        public ITrackable Parse(string line)
        {
            if (line == null)
            {
                return(null);
            }
            // 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
                logger.LogError(null);
                return(null);
            }

            Point    coords     = new Point();
            TacoBell restaurant = new TacoBell();

            coords.Latitude     = double.Parse(cells[0]);
            coords.Longitude    = double.Parse(cells[1]);
            restaurant.Location = coords;


            restaurant.Name = cells[2];
            return(restaurant);
        }
Exemplo n.º 4
0
        public ITrackable Parse(string line)
        {
            TacoBell restaurant = new TacoBell();

            if (line == null)
            {
                return(null);
            }


            var cells = line.Split(',');

            if (cells.Length < 3)
            {
                logger.LogError(null);
                return(null);
            }
            // Do not fail if one record parsing fails, return null
            // TODO Implement
            Point coordinates = new Point();

            coordinates.Latitude  = double.Parse(cells[0]);
            coordinates.Longitude = double.Parse(cells[1]);
            restaurant.Location   = coordinates;
            restaurant.Name       = cells[2];
            return(restaurant);
        }
Exemplo n.º 5
0
        public ITrackable Parse(string line)
        {
            logger.LogInfo("Begin parsing");

            var cells = line.Split(',');

            if (cells.Length < 3)
            {
                logger.LogError("Line doesn't have complete info");

                return(null);
            }

            var lat  = double.Parse(cells[0]);
            var lon  = double.Parse(cells[1]);
            var name = cells[2];

            var point = new Point();

            point.Latitude  = lat;
            point.Longitude = lon;

            TacoBell bell = new TacoBell();

            bell.Location = point;
            bell.Name     = name;

            return(bell);
        }
Exemplo n.º 6
0
        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 ','
            string [] cells = line.Split(',');

            // If your array.Length is less than 3, something went wrong
            if (cells.Length < 3)
            {
                logger.LogError("If length is less than 3 you stupid");
                return(null);
            }

            double lat  = double.Parse(cells[0]);
            double lon  = double.Parse(cells[1]);
            string name = cells[2];


            var TB       = new TacoBell();
            var Location = new Point();

            Location.Latitude  = lat;
            Location.Longitude = lon;

            TB.Name     = name;
            TB.Location = Location;

            return(TB);
        }
Exemplo n.º 7
0
        public ITrackable Parse(string line)
        {
            logger.LogInfo("Begin parsing");

            // 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
                // Do not fail if one record parsing fails, return null
                return(null); // TODO Implement
            }

            // grab the latitude from your array at index 0
            double latitude = double.Parse(cells[0]);
            // grab the longitude from your array at index 1
            double longitude = double.Parse(cells[1]);
            // grab the name from your array at index 2
            string name = cells[2];

            // Then, you'll need an instance of the TacoBell class
            TacoBell tacoBell = new TacoBell();

            // With the name and point set correctly
            tacoBell.Name     = name;
            tacoBell.Location = new Point()
            {
                Latitude  = latitude, //connects these two to the Array value
                Longitude = longitude
            };

            return(tacoBell);
        }
Exemplo n.º 8
0
        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 ','

            if (line == null)
            {
                return(null);
            }

            var cells = line.Split(',');

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

            double lattitude, longitude;

            double.TryParse(cells[0], out lattitude);
            double.TryParse(cells[1], out longitude);
            string name = cells[2];
            // Do not fail if one record parsing fails, return null
            TacoBell TB = new TacoBell();

            TB.Name     = name;
            TB.Location = new Point()
            {
                Latitude = lattitude, Longitude = longitude
            };

            return(TB);
        }
        public ITrackable Parse(string line)
        {
            var cells = line.Split(',');

            if (cells.Length < 3)
            {
                return(null);
            }

            string lat  = cells[0];
            string lon  = cells[1];
            string city = cells[2];

            double _lat = double.Parse(lat);
            double _lon = double.Parse(lon);

            TacoBell bell1 = new TacoBell();

            bell1.Name     = city;
            bell1.Location = new Point {
                Latitude = _lat, Longitude = _lon
            };



            return(bell1);



            // TODO Implement
        }
Exemplo n.º 10
0
        public ITrackable Parse(string line)
        {
            logger.LogInfo("Begin parsing");
            var cells = line.Split(',');

            if (cells.Length < 3)
            {
                logger.LogInfo("cell array less than 3 items");
                return(null);
            }

            string latitudeString  = cells[0];
            string longitudeString = cells[1];
            string coordName       = cells[2];

            double latitude  = double.Parse(latitudeString);
            double longitude = double.Parse(longitudeString);

            var tacoBell = new TacoBell();

            tacoBell.Name = coordName;
            Point location = new Point();

            location.Latitude  = latitude;
            location.Longitude = longitude;
            tacoBell.Location  = location;

            return(tacoBell);
        }
Exemplo n.º 11
0
        public ITrackable Parse(string line)
        {
            logger.LogInfo("Begin parsing");

            if (line == null)
            {
                return(null);
            }
            var cells = line.Split(',');

            if (cells.Length < 3)
            {
                logger.LogError("Not enough items for input.");

                return(null);
            }

            var latitude = double.Parse(cells[0]);
            var logitude = double.Parse(cells[1]);
            var name     = cells[2];

            var point = new Point();

            point.Longitude = logitude;
            point.Latitude  = latitude;

            var tacobell = new TacoBell();

            tacobell.Name     = name;
            tacobell.Location = point;

            return(tacobell);
        }
Exemplo n.º 12
0
        public ITrackable Parse(string line)
        {
            logger.LogInfo("Begin parsing");

            var cells = line.Split(',');

            if (cells.Length < 3)
            {
                logger.LogError("Array length is less than 3");
                return(null);
            }

            double latitude = double.Parse(cells[0]);

            double longitude = double.Parse(cells[1]);

            var name = cells[2];

            var taco  = new TacoBell();
            var point = new Point();

            point.Latitude  = latitude;
            point.Longitude = longitude;

            taco.Name     = name;
            taco.Location = point;

            return(taco);
        }
Exemplo n.º 13
0
        public ITrackable Parse(string line)
        {
            logger.LogInfo("Begin parsing");


            var cells = line.Split(',');


            if (cells.Length < 3)
            {
                logger.LogError("Insufficient Information: Could not parse.", null);

                return(null);
            }


            var lat = double.Parse(cells[0]);

            var longi = double.Parse(cells[1]);

            var name = cells[2];

            var point = new Point();

            point.Latitude  = lat;
            point.Longitude = longi;

            TacoBell tacoBell = new TacoBell();

            tacoBell.Location = point;
            tacoBell.Name     = name;

            return(tacoBell);
        }
Exemplo n.º 14
0
        public ITrackable Parse(string line)
        {
            if (line == null)
            {
                return(null);
            }
            logger.LogInfo("Begin parsing");

            // 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)
            {
                logger.LogInfo("Array is less than 3");
                return(null);
            }
            //double.TryParse(cells[0], out double Latitude);
            //double.TryParse(cells[1], out double Longitude);
            string name = cells[2];

            if (double.TryParse(cells[0], out double Latitude) == false)
            {
                logger.LogInfo("Latitude failed");
                return(null);
            }
            if (double.TryParse(cells[1], out double Longitute) == false)
            {
                logger.LogInfo("Longitude fail");
                return(null);
            }

            var tacoBell1 = new TacoBell();

            tacoBell1.Name = name;
            Point Location = new Point();

            Location.Latitude  = Latitude;
            Location.Longitude = Longitute;
            tacoBell1.Location = Location;
            return(tacoBell1);
            // 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
            // Do not fail if one record parsing fails, return null
            // TODO Implement
        }
Exemplo n.º 15
0
        public ITrackable Parse(string line)
        {
            string x = "34.073638,-84.677017,Taco Bell Acwort...";

            //cells[0] = "34.073638";
            //cells[1] = "-84.677017";
            //cells[2] = "Taco Bell Acwort...";

            // double lat = 34.073638;

            //double longitude = -84.677017;

            //string name = "Taco Bell Acwort";

            var taco = new TacoBell();

            taco.Name = "Taco Bell Acwort";

            //taco.Location.Longitude =-84.677017;

            //taco.Location.Longitude = 34.073638;

            logger.LogInfo("Begin parsing");
            var cells = line.Split(',');


            if (cells.Length < 3)
            {
                logger.LogError("Array Length is less than 3");

                return(null);
            }


            double lat = 0;

            if (!double.TryParse(cells[0], out lat))
            {
                logger.LogInfo($"{cells[0]} was unable to be converted to a double");
            }

            double longitude = 0;

            if (!double.TryParse(cells[1], out longitude))
            {
                logger.LogInfo($"{cells[1]} was unable to covenverted to a double");
            }

            string name = cells[2];


            var point = new Point();

            point.Latitude  = lat;
            point.Longitude = longitude;
            taco.Name       = name;
            taco.Location   = point;
            return(taco);
        }
Exemplo n.º 16
0
        public ITrackable Parse(string line)
        {
            logger.LogInfo("Begin parsing");

            // 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
                logger.LogWarning("Something went wrong.");
                // Do not fail if one record parsing fails, return null
                return(null); // TODO Implement
            }

            double latitude;
            double longitude;

            try
            {
                latitude  = double.Parse(cells[0]);
                longitude = double.Parse(cells[1]);
            }
            catch
            {
                return(null);
            }

            string name = cells[2];
            // 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

            var tacoBell = new TacoBell();

            tacoBell.Name = name;

            Point loc1 = new Point();

            loc1.Latitude  = latitude;
            loc1.Longitude = longitude;

            tacoBell.Location = loc1;

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

            return(tacoBell);
        }
Exemplo n.º 17
0
        public ITrackable Parse(string line)
        {
            if (line == null)
            {
                return(null);
            }

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

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

            // grab the latitude from your array at index 0
            string latitude = cells[0];
            // grab the longitude from your array at index 1
            string longitude = cells[1];
            // grab the name from your array at index 2
            string name = cells[2];
            // Your going to need to parse your string as a `double`
            bool isNumber = double.TryParse(latitude, out double LatNumber);

            if (isNumber == false)
            {
                return(null);
            }
            // which is similar to parsing a string as an `int`
            isNumber = double.TryParse(longitude, out double LonNumber);
            if (isNumber == false)
            {
                return(null);
            }
            // You'll need to create a TacoBell class

            // that conforms to ITrackable

            // Then, you'll need an instance of the TacoBell class
            TacoBell taco = new TacoBell();

            // With the name and point set correctly
            taco.Name = name;
            Point point = new Point();

            point.Latitude  = LatNumber;
            point.Longitude = LonNumber;

            taco.Location = point;
            // Then, return the instance of your TacoBell class
            return(taco);
            // Since it conforms to ITrackable
        }
Exemplo n.º 18
0
        public ITrackable Parse(string line)
        {
            logger.LogInfo("Begin parsing");

            // 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
                // Do not fail if one record parsing fails, return null
                return(null); // TODO Implement
            }
            double lat;

            double.TryParse(cells[0], out lat);

            double lng;

            double.TryParse(cells[1], out lng);

            var name = cells[2];

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



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



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

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

            var taco = new TacoBell();

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

            taco.Name = name;
            var point = new Point();

            point.Latitude  = lat;
            point.Longitude = lng;

            taco.Location = point;

            return(taco);
        }
Exemplo n.º 19
0
        public ITrackable Parse(string line)
        {
            logger.LogInfo("Begin parsing");

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

            // If your array.Length is less than 3, something went wrong
            if (cells.Length < 3)
            {
                // Log that and return null
                logger.LogError("Error, did not split");

                // Do not fail if one record parsing fails, return null
                return(null); // TODO Implement
            }
            // D- Your going to need to parse your string as a `double`
            // which is similar to parsing a string as an `int`
            // grab the latitude from your array at index 0
            double lat = 0;

            if (double.TryParse(cells[0], out lat) == false)
            {
                logger.LogError($"{cells[0]} Bad data, unable to parse latitude.");
            }

            // grab the longitude from your array at index 1
            double lon = 0;

            if (double.TryParse(cells[1], out lon) == false)
            {
                logger.LogError($"{cells[1]} Bad data, unable to parse longitude.");
            }

            // grab the name from your array at index 2
            var loc = cells[2];

            if (loc == null || loc.Length == 0)
            {
                logger.LogError("File doesnt cotain Name");
            }

            // D- 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
            var coord = new Point(lon, lat);
            var taco1 = new TacoBell();

            taco1.Location = coord;
            taco1.Name     = loc;

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

            return(taco1);
        }
Exemplo n.º 20
0
        public ITrackable Parse(string line)
        {
            logger.LogInfo("Begin parsing");

            // 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

                logger.LogError("Less than 3 items in imput");

                // Do not fail if one record parsing fails, return null

                return(null); // TODO Implement
            }

            // grab the latitude from your array at index 0

            var lati = double.Parse(cells[0]);

            // grab the longitude from your array at index 1

            var longi = double.Parse(cells[1]);

            // grab the name from your array at index 2

            var tacoBellName = cells[2];

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

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

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

            var locationPoint = new Point();

            locationPoint.Latitude  = lati;
            locationPoint.Longitude = longi;

            var tacoBell = new TacoBell()
            {
                Name     = tacoBellName,
                Location = locationPoint,
            };


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

            return(tacoBell);
        }
Exemplo n.º 21
0
        public ITrackable Parse(string line)
        {
            logger.LogInfo("Begin parsing");

            // 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
                // Do not fail if one record parsing fails, return null
                return(null); // TODO Implement
            }

            // grab the latitude from your array at index 0
            var TacoBellLatitiude = cells[0];



            // grab the longitude from your array at index 1

            var TacoBellLongitude = cells[1];
            // grab the name from your array at index 2

            var TacoBellName = cells[2];
            // Your going to need to parse your string as a `double`

            double ValuesConvertedLongitude = double.Parse(TacoBellLongitude);
            double ValuesConvertedLatitude  = double.Parse(TacoBellLatitiude);
            // 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



            var point = new Point()
            {
                Latitude = ValuesConvertedLatitude, Longitude = ValuesConvertedLongitude
            };
            var convertedtacobell = new TacoBell()
            {
                Name = TacoBellName, Location = point
            };


            // With the name and point set correctly

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

            return(convertedtacobell);
        }
Exemplo n.º 22
0
        public void ShouldParseLatitude(string line, double expected)
        {
            var tacoParser = new TacoParser();
            var tacoBell   = new TacoBell();

            var actual = tacoParser.Parse(line);

            Assert.Equal(actual.Location.Latitude, expected);
        }
Exemplo n.º 23
0
        public ITrackable Parse(string line)
        {
            logger.LogInfo("Begin parsing");

            TacoBell tacoBell = new TacoBell();
            double   longitude;
            double   latitude;

            // Do not fail if one record parsing fails, return null
            // TODO Implement
            // Take your line and use line.Split(',') to split it up into an array of strings, separated by the char ','
            string[] cells = line.Split(',');

            // If your array.Length is less than 3, something went wrong
            if (cells.Length < 3 || cells.Length > 4)
            {
                // Log that and return null
                logger.LogError("Array length incoreect.");

                return(null);
            }

            // grab the latitude from your array at index 0
            string s_latitude = cells[0];
            // grab the longitude from your array at index 1
            string s_longitude = cells[1];

            // grab the name from your array at index 2
            tacoBell.Name = cells[2];
            // Your going to need to parse your string as a `double`
            // which is similar to parsing a string as an `int`
            logger.LogInfo("Changing longitude into a double");
            bool sucess = double.TryParse(s_longitude, out longitude);

            logger.LogInfo("Changing latitude into a double");
            bool Sucess = double.TryParse(s_latitude, out latitude);

            if (Sucess == false || sucess == false)
            {
                logger.LogError("latitude or longitude is not a number");
                return(null);
            }

            // You'll need to create a TacoBell class
            // that conforms to ITrackable
            Point loc = new Point(latitude, longitude);

            tacoBell.Location = loc;
            return(tacoBell);

            // 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
        }
Exemplo n.º 24
0
        public ITrackable Parse(string line)
        {
            logger.LogInfo("Begin parsing");

            // 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

                logger.LogInfo(line);
                // Do not fail if one record parsing fails, return null
                return(null); // TODO Implement
            }

            // grab the latitude from your array at index 0
            double latitude = 0;
            var    testLat  = double.TryParse(cells[0], out latitude);
            // grab the longitude from your array at index 1
            double longitude = 0;
            var    testLong  = double.TryParse(cells[1], out longitude);
            // grab the name from your array at index 2
            string name = cells[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
            TacoBell tacobell = new TacoBell();

            tacobell.Name = name;
            Point num1 = new Point();

            num1.Longitude = longitude;
            num1.Latitude  = latitude;

            if (testLat == false || testLong == false)
            {
                logger.LogError("Could Not Parse.", null);
            }

            tacobell.Location = num1;

            // 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

            return(tacobell);
        }
Exemplo n.º 25
0
        public void TacoBellTest()
        {
            //Arrange
            var tacoParser = new TacoParser();

            //Act
            var actual   = tacoParser.Parse("34.073638, -84.677017, Taco Bell Acwort...");
            var tacoBell = new TacoBell();

            //Assert
            Assert.IsType(tacoBell.GetType(), actual);
        }
Exemplo n.º 26
0
        public ITrackable Parse(string line)
        {
            logger.LogInfo("Begin parsing");

            // 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)
            {
                logger.LogError("Line doesn't complete info");

                return(null);
            }

            // grab the latitude from your array at index 0
            var lat = double.Parse(cells[0]);


            // grab the longitude from your array at index 1
            var lng = double.Parse(cells[1]);

            // grab the name from your array at index 2
            var name = cells[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

            var point = new Point();

            point.Latitude  = lat;
            point.Longitude = lng;

            var tacoBell = new TacoBell();

            tacoBell.Name     = name;
            tacoBell.Location = point;
            tacoBell.Name     = name;



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

            return(tacoBell);
        }
Exemplo n.º 27
0
        public void ShouldDoSomething()
        {
            // TODO: Complete Something, if anything
            var tacobell = new TacoBell();
            //Arrange
            var tacoParser = new TacoParser();

            //Act
            var actual = tacoParser.Parse("34.073638, -84.677017, Taco Bell Acwort...");

            //Assert
            Assert.NotNull(actual);
        }
Exemplo n.º 28
0
        public ITrackable Parse(string line)
        {
            logger.LogInfo("Begin parsing");

            // 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
                // Do not fail if one record parsing fails, return null
                return(null); // TODO Implement
            }

            // grab the latitude from your array at index 0
            var latitude = double.Parse(cells[0]);
            // grab the longitude from your array at index 1
            var longitude = double.Parse(cells[1]);
            // grab the name from your array at index 2
            var name = cells[2];

            // You're 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 (meaning make a new instance of Point())

            //make new instance of Point() struct so give it values
            var location = new Point();

            location.Latitude  = latitude;
            location.Longitude = longitude;

            //new instance of TacoBell() so you need to include ITrackable as well
            var tacoBell = new TacoBell()
            {
                Name     = name,
                Location = location
            };

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

            return(tacoBell);

            //return null;
        }
Exemplo n.º 29
0
        public ITrackable Parse(string line)
        {
            logger.LogInfo("Begin parsing");

            // 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
                // Do not fail if one record parsing fails, return null
                // TODO Implement
                logger.LogError("Less than 3 elements in record.");
            }

            var    tacoBell = new TacoBell();
            string name     = cells[2];

            // grab the name from your array at index 2
            tacoBell.Name = name;
            Point location = new Point();

            double latitude;
            double longitude;

            // grab the latitude from your array at index 0
            if (double.TryParse(cells[0], out latitude))
            {
                location.Latitude = latitude;
            }
            else
            {
                logger.LogError("Could not parse latitude.");
            }

            // grab the longitude from your array at index 1
            if (double.TryParse(cells[1], out longitude))
            {
                location.Longitude = longitude;
            }
            else
            {
                logger.LogError("Could not parse longitude.");
            }

            tacoBell.Location = location;

            return(tacoBell);
        }
Exemplo n.º 30
0
        public ITrackable Parse(string line)
        {
            logger.LogInfo("Begin parsing");

            // 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)
            {
                logger.LogError("array length is less than 3", new System.Exception());
                // Log that and return null
                // Do not fail if one record parsing fails, return null

                return(null); // TODO Implement
            }

            // grab the latitude from your array at index 0
            var latitude = cells[0];

            // grab the longitude from your array at index 1
            var longitude = cells[1];
            // grab the name from your array at index 2
            var name = cells[2];


            // Your going to need to parse your string as a `double`
            var doublelat = double.Parse(latitude);
            // which is similar to parsing a string as an `int`
            var doublelong = double.Parse(longitude);
            // 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
            var point = new Point();

            point.Latitude  = doublelat;
            point.Longitude = doublelong;

            TacoBell tacoBell = new TacoBell();

            tacoBell.Name     = name;
            tacoBell.Location = point;
            // Then, return the instance of your TacoBell class
            // Since it conforms to ITrackable

            return(tacoBell);
        }