Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Rules: This is a grouped assignment. Only the team leader has to submit the solution. The attached source code should be modified and submitted. Your

Rules:

  1. This is a grouped assignment. Only the team leader has to submit the solution.
  2. The attached source code should be modified and submitted.
  3. Your submission WILL BE REJECTED if you used any other language or created a separate project. You must make changes to this current source code.
  4. Once the code is complete, run your test cases before submitting the code.

Objective:

  1. The program should input two strings: start and destination
  2. The output of the program should be a Path containing a list of BusRoute objects specifying Origin as where to take bus from and Terminus as where to drop off.
  3. The output should also mention the length of the path in terms of number of stops which occurred during travel.
  4. Secondary objective is to provide an optimal solution, i.e. the shortest path which has minimum length, or number of stops in between.

Code:

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_2

Step: 3

blur-text-image_3

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

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

4th Edition

0805360476, 978-0805360479

More Books

Students also viewed these Databases questions

Question

How is the NDAA used to shape defense policies indirectly?

Answered: 1 week ago