Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

using System; using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Xml.Linq; using CsvHelper; using CsvHelper.Configuration; namespace Assignment4 { public class

using System; using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Xml.Linq; using CsvHelper; using CsvHelper.Configuration;

namespace Assignment4 { public class BusRoute { public string Origin { get; set; } public string Terminus { get; set; } public string Name { get; set; } public int Stops { get; set; } public string[] Route { get; set; } }

internal class Program { static void Main(string[] args) { Console.WriteLine("Enter your "); string Start = Console.ReadLine();

Console.WriteLine(""); string Destination = Console.ReadLine();

string filePath = "data.csv"; List busRoutes = ReadCsv(filePath); foreach (var route in busRoutes) { Console.WriteLine($"Origin: {route.Origin}, Terminus: {route.Terminus}, Name: {route.Name}, Stops: {route.Stops}"); Console.WriteLine("Route: " + string.Join(" > ", route.Route)); Console.WriteLine(); } Console.ReadKey(); }

static List ReadCsv(string filePath) { List busRoutes = new List(); using (var reader = new StreamReader(filePath)) using (var csv = new CsvReader(reader, new CsvConfiguration(CultureInfo.InvariantCulture) { Delimiter = "\t", HasHeaderRecord = true })) { while (csv.Read()) { BusRoute route = new BusRoute(); route.Origin = csv.GetField(0); route.Terminus = csv.GetField(1); route.Name = csv.GetField(2); route.Route = csv.GetField(4).Split('>'); route.Stops = 1; // Objective 2: include 'stops' in your object for optimization busRoutes.Add(route); } } return busRoutes; }

static List GetPath(List busRoutes, string start, string destination) { List myRoute = new List(); // Objective 1: find out all any path which takes you from start to destination return myRoute; }

static List GetOptimalPath(List busRoutes, string start, string destination) { List myRoute = new List(); // Objective 1: find out the most optimal path which takes you from start to destination return myRoute; } } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database Foundations Technology Fundamentals For IT Success

Authors: Bob Bryla

1st Edition

0782143725, 9780782143720

More Books

Students also viewed these Databases questions

Question

Methods of Delivery Guidelines for

Answered: 1 week ago