Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hey guys! Im doing some lab task in C# but i struggle a bit with the last one. I

ID: 3648833 • Letter: H

Question

Hey guys!

Im doing some lab task in C# but i struggle a bit with the last one.
I am fairly new to C # so I will not boast of myself that I can all too much but I need help in this type of task by people who can a lot better than me.
I've done some of the task but are unsure whether it is entirely appropriate. I would appreciate it if someone could help me because im really stuck and i cant continue with the rest of the task im working with until im done with this.



This is the task im telling you about:
----------------------------------

You should create a program that manages a set of POI (Point of Interest) points.
The points are map coordinates of longitude, latitude and altitude.
In addition, it should be possible to associate a descriptive text to each point.

Example of a point: [68.123434, 17.57574, 145.7, "The major birch beside the bridge"].
Each point must be set by using two floating point values(double) and a string.

In the program we should be able to register new points and obtain a list of all registered points.
It shall not be possible to add points with the same coordinate,
which tells that it will not be possible to register two points that have exactly the same latitude and longitude
(in this case, the program provides an error message).

You must create a struct called POI and a class called MyPOIs.
POI will contain variables / members longitude, latitude and string.
MyPOIs shall contain a POI table of size similar to that sent to the constructor to MyPOIs.
Members of the POI class will be private and could be changed by using properties.

Objects of type MyPOIs to be indexed as it were a table. Here you would use an indexer.
The following shall be possible from a test program:
------------------------------------------------

class POIManager
{
static void Main (string [] args)
{
POI poi1 = new POI (68.123434, 17.575742, 145.7, "The big birch tree next to the bridge");
POI poi2 = new POI (68.144433, 17.433222, 153.1, "bomb shelter at the side of the road");
/ / Prints single point:
Console.WriteLine (poi1);

/ / The constructor creates a POI table with room for 100 elements:
MyPOIs mypois = new MyPOIs (100);
mypois [0] = p1;
mypois [1] = p2;
mypois [2] = new POI (67.133221, 17.111321, 133.5, "pine on the hill")
Console.WriteLine (mypois);

Console.WriteLine ("Distance between points 1 and 2:" this.CalculateDistance (mypois [0], mypois [1]);
}
}




You should therefore override ToString () in both the POI and MyPOIs.
In toString in class POI should use String.Format (...) to build and return a string (all members print).
In ToString () in MyPOIs use a StringBuilder instead of String to construct and return a string of all the points.
Items are printed so that each point on a separate line.

=============================================================================

This is what i have done:
------------------------

using System;

public struct Poi
{
private double longitude,latitude;
private String label;

// Constructor
public Poi(double poi1, double poi2, String aLabel)
{
this.longitude = poi1;
this.latitude = poi2;
this.label = aLabel;
}

public double longitude
{
get { return longitude ; }
set { longitude = value; }
}
public double latitude
{
get { return latitude; }
set { latitude = value; }
}

public String Label
{
get { return label; }
set { label = value; }
}

// ToString method
public override string ToString()
{
return (String.Format("({0},{1},{2})", longitude, latitude, label));
}


===================================================================

class MyPOIs

private Poi[] MyPOIs;

public MyPOIs(int size)
{
MyPOIs = new Poi[size];

Explanation / Answer

class POIManager { static void Main (string [] args) { POI poi1 = new POI (68.123434, 17.575742, 145.7, "The big birch tree next to the bridge"); POI poi2 = new POI (68.144433, 17.433222, 153.1, "bomb shelter at the side of the road"); / / Prints single point: Console.WriteLine (poi1); / / The constructor creates a POI table with room for 100 elements: MyPOIs mypois = new MyPOIs (100); mypois [0] = p1; mypois [1] = p2; mypois [2] = new POI (67.133221, 17.111321, 133.5, "pine on the hill") most of you programme is correct i guess Console.WriteLine (mypois); Console.WriteLine ("Distance between points 1 and 2:" this.CalculateDistance (mypois [0], mypois [1]); } } public struct Poi { private double longitude,latitude; private String label; // Constructor public Poi(double poi1, double poi2, String aLabel) { this.longitude = poi1; this.latitude = poi2; this.label = aLabel; } public double longitude { get { return longitude ; } set { longitude = value; } } public double latitude { get { return latitude; } set { latitude = value; } } public String Label { get { return label; } set { label = value; } } // ToString method public override string ToString() { return (String.Format("({0},{1},{2})", longitude, latitude, label)); } class MyPOIs private Poi[] MyPOIs; public MyPOIs(int size) { MyPOIs = new Poi[size];