feat: complete "Lab5.TouristInformationCenter"
This commit is contained in:
parent
c099ec3bb3
commit
c1dff4fabf
@ -2,7 +2,16 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="Players.csv">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Teams.csv">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -37,22 +37,39 @@ namespace Lab5.TouristInformationCenter
|
||||
for (int i = 2; i < lines.Count; i++)
|
||||
{
|
||||
string line = lines[i];
|
||||
string[] values = line.Split(';');
|
||||
/* string name = values[0]; */
|
||||
/* string type = values[1]; */
|
||||
/* List<Weekday> workdays = new List<Weekday>(); */
|
||||
/* for (int j = 1; j <= 7; j++) */
|
||||
/* { */
|
||||
/* if (int.Parse(values[j + 1]) == 1) */
|
||||
/* { */
|
||||
/* workdays.Add((Weekday)j); */
|
||||
/* } */
|
||||
/* } */
|
||||
/* double price = double.Parse(values[9]); */
|
||||
/* bool hasGuide = int.Parse(values[10]) == 1; */
|
||||
string[] values = line.Split(';', StringSplitOptions.RemoveEmptyEntries);
|
||||
string name = values[0];
|
||||
string address = values[1];
|
||||
int year = int.Parse(values[2]);
|
||||
|
||||
/* Location location = new Location(name, city, manager, type, workdays, price, hasGuide); */
|
||||
/* container.Add(location); */
|
||||
Location location;
|
||||
if (values.Length == 5)
|
||||
{
|
||||
string author = values[3];
|
||||
string monumentName = values[4];
|
||||
location = new Statue(city, manager, name, address, year, author, monumentName);
|
||||
}
|
||||
else if (values.Length == 13)
|
||||
{
|
||||
string type = values[3];
|
||||
List<Weekday> workdays = new List<Weekday>();
|
||||
for (int j = 1; j <= 7; j++)
|
||||
{
|
||||
if (int.Parse(values[j + 3]) == 1)
|
||||
{
|
||||
workdays.Add((Weekday)j);
|
||||
}
|
||||
}
|
||||
double price = double.Parse(values[11]);
|
||||
bool hasGuide = int.Parse(values[12]) == 1;
|
||||
location = new Museum(city, manager, name, address, year, type, workdays, price, hasGuide);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"Attempt to parse unknown line: {lines[i]}");
|
||||
}
|
||||
|
||||
container.Add(location);
|
||||
}
|
||||
return container;
|
||||
}
|
||||
@ -128,17 +145,28 @@ namespace Lab5.TouristInformationCenter
|
||||
|
||||
private static string CreateLocationLine(Location location)
|
||||
{
|
||||
/* string workDays = ""; */
|
||||
/* workDays += location.Workdays.Contains(Weekday.Monday) ? "1" : "0"; */
|
||||
/* workDays += location.Workdays.Contains(Weekday.Tuesday) ? ";1" : ";0"; */
|
||||
/* workDays += location.Workdays.Contains(Weekday.Wednesday) ? ";1" : ";0"; */
|
||||
/* workDays += location.Workdays.Contains(Weekday.Thursday) ? ";1" : ";0"; */
|
||||
/* workDays += location.Workdays.Contains(Weekday.Friday) ? ";1" : ";0"; */
|
||||
/* workDays += location.Workdays.Contains(Weekday.Saturday) ? ";1" : ";0"; */
|
||||
/* workDays += location.Workdays.Contains(Weekday.Sunday) ? ";1" : ";0"; */
|
||||
/* */
|
||||
/* return String.Join(";", location.City, location.Name, workDays, location.Price); */
|
||||
return "";
|
||||
if (location is Museum)
|
||||
{
|
||||
Museum m = location as Museum;
|
||||
string workDays = "";
|
||||
workDays += m.Workdays.Contains(Weekday.Monday) ? "1" : "0";
|
||||
workDays += m.Workdays.Contains(Weekday.Tuesday) ? ";1" : ";0";
|
||||
workDays += m.Workdays.Contains(Weekday.Wednesday) ? ";1" : ";0";
|
||||
workDays += m.Workdays.Contains(Weekday.Thursday) ? ";1" : ";0";
|
||||
workDays += m.Workdays.Contains(Weekday.Friday) ? ";1" : ";0";
|
||||
workDays += m.Workdays.Contains(Weekday.Saturday) ? ";1" : ";0";
|
||||
workDays += m.Workdays.Contains(Weekday.Sunday) ? ";1" : ";0";
|
||||
return String.Join(";", m.Name, m.Address, m.Year, m.Type, workDays, m.Price, m.HasGuide ? "1" : "0");
|
||||
}
|
||||
else if (location is Statue)
|
||||
{
|
||||
Statue s = location as Statue;
|
||||
return String.Join(";", s.Name, s.Address, s.Year, s.Author, s.MonumentName);
|
||||
} else
|
||||
{
|
||||
throw new Exception("What you doin??");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -157,6 +185,26 @@ namespace Lab5.TouristInformationCenter
|
||||
File.WriteAllLines(filename, lines, Encoding.UTF8);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write and encode a list of statues from a container to a file
|
||||
/// </summary>
|
||||
/// <param name="filename">Target file</param>
|
||||
/// <param name="container">Target container</param>
|
||||
public static void WriteStatues(string filename, LocationsContainer container)
|
||||
{
|
||||
using (StreamWriter writer = File.CreateText(filename))
|
||||
{
|
||||
for (int i = 0; i < container.Count; i++)
|
||||
{
|
||||
Statue statue = container.Get(i) as Statue;
|
||||
if (statue != null)
|
||||
{
|
||||
writer.WriteLine("{0};{1};{2};{3};{4}", statue.Name, statue.Address, statue.Year, statue.Author, statue.MonumentName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write and encode a list of locations to a file from a register.
|
||||
/// </summary>
|
||||
@ -186,15 +234,15 @@ namespace Lab5.TouristInformationCenter
|
||||
return;
|
||||
}
|
||||
|
||||
Console.WriteLine(new string('-', 123));
|
||||
/* Console.WriteLine("| {0,-20} | {1,-10} | {2,-20} | {3,-10} | {4,18} | {5,13} | {6,-4} |", "Vardas", "Miestas", "Atsakingas", "Tipas", "Darbo dienų kiekis", "Kaina", "Turi gidą?"); */
|
||||
Console.WriteLine(new string('-', 123));
|
||||
Console.WriteLine(new string('-', 84));
|
||||
Console.WriteLine("| {0,-10} | {1,-20} | {2,-18} | {3,-15} | {4,5} |", "Miestas", "Atsakingas", "Vardas", "Adresas", "Metai");
|
||||
Console.WriteLine(new string('-', 84));
|
||||
for (int i = 0; i < container.Count; i++)
|
||||
{
|
||||
Location l = container.Get(i);
|
||||
/* Console.WriteLine("| {0,-20} | {1,-10} | {2,-20} | {3,-10} | {4,18} | {5,13:f2} | {6,-10} |", l.Name, l.City, l.Manager, l.Type, l.Workdays.Count, l.Price, l.HasGuide ? "Taip" : "Ne"); */
|
||||
Console.WriteLine("| {0,-10} | {1,-20} | {2,-18} | {3,-15} | {4,5} |", l.City, l.Manager, l.Name, l.Address, l.Year);
|
||||
}
|
||||
Console.WriteLine(new string('-', 123));
|
||||
Console.WriteLine(new string('-', 84));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -2,7 +2,19 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="LocationsAlytus.csv">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="LocationsKaunas.csv">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="LocationsVilnius.csv">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -3,19 +3,19 @@ namespace Lab5.TouristInformationCenter
|
||||
{
|
||||
abstract class Location
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string City { get; set; }
|
||||
public string Manager { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Address { get; set; }
|
||||
public int Year { get; set; }
|
||||
public string Manager { get; set; }
|
||||
|
||||
public Location(string name, string city, string address, int year, string manager)
|
||||
public Location(string city, string manager, string name, string address, int year)
|
||||
{
|
||||
Name = name;
|
||||
City = city;
|
||||
Manager = manager;
|
||||
Name = name;
|
||||
Address = address;
|
||||
Year = year;
|
||||
Manager = manager;
|
||||
}
|
||||
|
||||
public int CompareTo(Location other)
|
||||
|
@ -1,2 +1,11 @@
|
||||
Alytus
|
||||
Ona Onaite
|
||||
AlytausMuziejusZ;GatveZ;1999;Dailė;1;0;0;0;1;0;1;3,40;0
|
||||
AlytausMuziejusX;GatveX;2021;Computer;1;1;0;1;1;1;1;14,39;1
|
||||
StatulaH;KlebonasGatve2;1995;Tas Klebonas;Klebobo paminklas
|
||||
StatulaG;KlebonasGatve1;1995;Tas Klebonas;Klebobo paminklas
|
||||
StatulaP;KlebonasGatve2;1995;Tas Klebonas;Klebobo paminklas
|
||||
AlytausMuziejusV;GatveV;2014;Dailė;0;1;0;1;1;0;1;9,47;1
|
||||
AlytausMuziejusB;GatveX;1950;Space;1;1;0;0;0;0;1;1,99;1
|
||||
StatulaC;KlebonasGatve;1995;Tas Klebonas;Klebobo paminklas
|
||||
AlytausMuziejusN;GatveN;1920;Space;1;1;1;1;0;1;1;0,99;1
|
||||
|
|
@ -73,105 +73,6 @@ namespace Lab5.TouristInformationCenter
|
||||
locations[index] = location;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
/// <summary>
|
||||
/// Filter by property "HasGuide"
|
||||
/// </summary>
|
||||
/// <param name="hasGuide">Target value</param>
|
||||
/// <returns>A filtered container of locations</returns>
|
||||
public LocationsContainer FilterByGuide(bool hasGuide)
|
||||
{
|
||||
LocationsContainer filtered = new LocationsContainer();
|
||||
for (int i = 0; i < Count; i++)
|
||||
{
|
||||
Location location = locations[i];
|
||||
if (location.HasGuide == hasGuide)
|
||||
{
|
||||
filtered.Add(location);
|
||||
}
|
||||
}
|
||||
return filtered;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Filter by property "Type".
|
||||
/// </summary>
|
||||
/// <param name="type">Target type</param>
|
||||
/// <returns>A filtered container of locations</returns>
|
||||
public LocationsContainer FilterByType(string type)
|
||||
{
|
||||
LocationsContainer filtered = new LocationsContainer();
|
||||
for (int i = 0; i < Count; i++)
|
||||
{
|
||||
Location location = locations[i];
|
||||
if (location.Type == type)
|
||||
{
|
||||
filtered.Add(location);
|
||||
}
|
||||
}
|
||||
return filtered;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Filter by property "Price".
|
||||
/// </summary>
|
||||
/// <param name="maxPrice">Maximum allowed price to be included</param>
|
||||
/// <returns>A container with locations that dont't have a larger price then "maxPrice"</returns>
|
||||
public LocationsContainer FilterByPrice(double maxPrice)
|
||||
{
|
||||
LocationsContainer filtered = new LocationsContainer();
|
||||
for (int i = 0; i < Count; i++)
|
||||
{
|
||||
Location location = locations[i];
|
||||
if (location.Price <= maxPrice)
|
||||
{
|
||||
filtered.Add(location);
|
||||
}
|
||||
}
|
||||
return filtered;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return a list of "active" locations from the contaner.
|
||||
/// A location is considered active if it is working at least some amount a week.
|
||||
/// </summary>
|
||||
/// <param name="threshold">Threshold which determines what is active</param>
|
||||
/// <returns>A container of "active" locations</returns>
|
||||
public LocationsContainer FilterByActivity(int threshold)
|
||||
{
|
||||
LocationsContainer filtered = new LocationsContainer();
|
||||
for (int i = 0; i < Count; i++)
|
||||
{
|
||||
Location location = locations[i];
|
||||
if (location.Workdays.Count >= threshold)
|
||||
{
|
||||
filtered.Add(location);
|
||||
}
|
||||
}
|
||||
return filtered;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Filter by property "Name"
|
||||
/// </summary>
|
||||
/// <param name="name">Target name</param>
|
||||
/// <returns>A filtered container</returns>
|
||||
public LocationsContainer FilterByName(string name)
|
||||
{
|
||||
LocationsContainer filtered = new LocationsContainer();
|
||||
for (int i = 0; i < Count; i++)
|
||||
{
|
||||
Location location = locations[i];
|
||||
if (location.Name == name)
|
||||
{
|
||||
filtered.Add(location);
|
||||
}
|
||||
}
|
||||
return filtered;
|
||||
}
|
||||
*/
|
||||
|
||||
/// <summary>
|
||||
/// Sort container by given comparator
|
||||
/// </summary>
|
||||
|
@ -1,8 +1,8 @@
|
||||
Kaunas
|
||||
Jonas Jonaitis
|
||||
KaunoMuziejus1;Dailė;1;0;0;0;1;0;1;3,40;0
|
||||
KaunoMuziejusB;Computer;1;1;0;1;1;1;1;14,39;1
|
||||
KaunoMuziejus3;History;0;1;0;0;1;0;0;3,26;0
|
||||
KaunoMuziejus4;Dailė;0;1;0;1;1;0;1;9,47;1
|
||||
KaunoMuziejus5;Space;1;1;0;0;0;0;1;1,99;1
|
||||
KaunoMuziejusB;Space;1;1;1;1;0;1;1;0,99;1
|
||||
KaunoMuziejus1;Gatve1;1998;Dailė;1;0;0;0;1;0;1;3,40;0
|
||||
KaunoMuziejusB;GatveB;2000;Computer;1;1;0;1;1;1;1;14,39;1
|
||||
KaunoMuziejus3;Gatve3;1969;History;0;1;0;0;1;0;0;3,26;0
|
||||
KaunoMuziejus4;Gatve4;1970;Dailė;0;1;0;1;1;0;1;9,47;1
|
||||
KaunoMuziejus5;Gatve5;1989;Space;1;1;0;0;0;0;1;1,99;1
|
||||
KaunoMuziejusB;GatveC;1991;Space;1;1;1;1;0;1;1;0,99;1
|
||||
|
|
@ -1,7 +1,7 @@
|
||||
Vilnius
|
||||
Petras Petraitis
|
||||
VilnausMuziejus1;Dailė;1;0;0;1;1;0;0;5,49;0
|
||||
VilnausMuziejus2;Computer;1;1;0;1;1;1;1;0,00;1
|
||||
VilnausMuziejusA;Dailė;0;1;1;1;1;0;0;1,23;0
|
||||
VilnausMuziejusA;Food;1;1;1;1;1;1;0;6,90;0
|
||||
VilnausMuziejus5;History;0;1;0;1;1;0;1;10,49;0
|
||||
VilnausMuziejus1;Gatve1;2020;Dailė;1;0;0;1;1;0;0;5,49;0
|
||||
VilnausMuziejus2;Gatve2;1978;Computer;1;1;0;1;1;1;1;0,00;1
|
||||
VilnausMuziejusA;GatveA;1990;Dailė;0;1;1;1;1;0;0;1,23;0
|
||||
StatulaO;OnosGatve;1989;Tas Ona;Onos paminklas
|
||||
VilnausMuziejus5;Gatve5;1999;History;0;1;0;1;1;0;1;10,49;0
|
||||
|
|
@ -5,14 +5,14 @@ namespace Lab5.TouristInformationCenter
|
||||
/// <summary>
|
||||
/// Class used for storing data related a single museum.
|
||||
/// </summary>
|
||||
class Location : Location
|
||||
class Museum : Location
|
||||
{
|
||||
public string Type { get; set; }
|
||||
public List<Weekday> Workdays { get; set; }
|
||||
public double Price { get; set; }
|
||||
public bool HasGuide { get; set; }
|
||||
|
||||
public Location(string name, string city, string address, int year, string manager, string type, List<Weekday> workdays, double price, bool hasGuide) : base(name, city, address, year, manager)
|
||||
public Museum(string city, string manager, string name, string address, int year, string type, List<Weekday> workdays, double price, bool hasGuide) : base(city, manager, name, address, year)
|
||||
{
|
||||
Type = type;
|
||||
Workdays = workdays;
|
||||
|
@ -7,7 +7,6 @@ namespace Lab5.TouristInformationCenter
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
// Read all museums from initial data files
|
||||
LocationsContainer container = InOutUtils.ReadLocations("LocationsKaunas.csv", "LocationsVilnius.csv", "LocationsAlytus.csv");
|
||||
Register register = new Register(container);
|
||||
Console.WriteLine("Visos vietos:");
|
||||
@ -19,42 +18,21 @@ namespace Lab5.TouristInformationCenter
|
||||
Console.WriteLine();
|
||||
|
||||
List<string> types = register.FindCommonTypesWithGuidesAtWeekends();
|
||||
Console.Write("Lankytinų vietų tipai kuriouse galima apsilankyti visuose miestuose savaitgaliais:");
|
||||
Console.WriteLine("Lankytinų vietų tipai kuriouse galima apsilankyti visuose miestuose savaitgaliais:");
|
||||
foreach (string type in types)
|
||||
{
|
||||
Console.WriteLine("* {0}", type);
|
||||
}
|
||||
Console.WriteLine();
|
||||
|
||||
/*
|
||||
// Write out a list of cities and if they have at least one museum that is free and with a guide
|
||||
List<string> cities = register.GetAllCities();
|
||||
foreach (string city in cities)
|
||||
{
|
||||
MuseumsContainer freeMuseumsWithGuide = register
|
||||
.FilterByCity(city)
|
||||
.FilterByPrice(0)
|
||||
.FilterByGuide(true);
|
||||
bool passesCriteria = freeMuseumsWithGuide.Count > 0;
|
||||
Console.WriteLine("{0}: {1}", city, passesCriteria ? "Taip" : "Ne");
|
||||
}
|
||||
Console.WriteLine();
|
||||
Console.Write("Įveskite norimas autorius: ");
|
||||
//string inputAuthor = Console.ReadLine();
|
||||
string inputAuthor = "Tas Klebonas";
|
||||
LocationsContainer locationsByAuthor = register.FindLocationsByAuthor(inputAuthor);
|
||||
locationsByAuthor.Sort(new LocationsComparatorByNameAddress());
|
||||
InOutUtils.WriteStatues("PaminklaiAutorius.csv", locationsByAuthor);
|
||||
|
||||
// Find all museums that are the most active
|
||||
MuseumsContainer mostActiveMuseums = register.FindMostActiveMuseums();
|
||||
Console.WriteLine("Aktyviausi muziejai:");
|
||||
InOutUtils.PrintMuseums(mostActiveMuseums);
|
||||
Console.WriteLine();
|
||||
|
||||
// Find museums that have duplicate names
|
||||
MuseumsContainer museumsWithDuplicateNames = register.FindMuseumsWithDuplicateNames();
|
||||
InOutUtils.WriteMuseums("Sutampta.csv", museumsWithDuplicateNames);
|
||||
|
||||
// Find all art museums and sort them
|
||||
MuseumsContainer artMuseums = register.FilterByType("Dailė");
|
||||
artMuseums.Sort();
|
||||
InOutUtils.WriteMuseums("Dailė.csv", artMuseums);
|
||||
*/
|
||||
InOutUtils.WriteLocations("Po1990.csv", register.FindLocationsAfterYear(1990));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ namespace Lab5.TouristInformationCenter
|
||||
int count = 0;
|
||||
for (int i = 0; i < AllLocations.Count; i++)
|
||||
{
|
||||
Location museum = AllLocations.Get(i) as Location;
|
||||
Museum museum = AllLocations.Get(i) as Museum;
|
||||
if (museum != null && museum.HasGuide)
|
||||
{
|
||||
count++;
|
||||
@ -85,7 +85,7 @@ namespace Lab5.TouristInformationCenter
|
||||
List<string> types = new List<string>();
|
||||
for (int i = 0; i < AllLocations.Count; i++)
|
||||
{
|
||||
Location museum = AllLocations.Get(i) as Location;
|
||||
Museum museum = AllLocations.Get(i) as Museum;
|
||||
if (museum != null && !types.Contains(museum.Type))
|
||||
{
|
||||
types.Add(museum.Type);
|
||||
@ -105,10 +105,11 @@ namespace Lab5.TouristInformationCenter
|
||||
{
|
||||
for (int i = 0; i < AllLocations.Count; i++)
|
||||
{
|
||||
Location museum = AllLocations.Get(i) as Location;
|
||||
Museum museum = AllLocations.Get(i) as Museum;
|
||||
if (museum != null && museum.Type == type && museum.City == city)
|
||||
{
|
||||
types[type]++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -130,7 +131,7 @@ namespace Lab5.TouristInformationCenter
|
||||
for (int i = 0; i < AllLocations.Count; i++)
|
||||
{
|
||||
Museum museum = AllLocations.Get(i) as Museum;
|
||||
if (museum != null && museum.Type == type && museum.HasGuide)
|
||||
if (museum != null && museum.Type == type && museum.HasGuide && (museum.Workdays.Contains(Weekday.Saturday) || museum.Workdays.Contains(Weekday.Sunday)))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -178,106 +179,5 @@ namespace Lab5.TouristInformationCenter
|
||||
}
|
||||
return locations;
|
||||
}
|
||||
|
||||
/*
|
||||
/// <summary>
|
||||
/// Return a list of active locations from the register.
|
||||
/// A location is considered active if it is working at least some amount a week.
|
||||
/// </summary>
|
||||
/// <param name="threshold">Threshold which determines what is active</param>
|
||||
/// <returns>A list of active locations</returns>
|
||||
public LocationsContainer FilterByActiveLocations(int threshold)
|
||||
{
|
||||
return AllLocations.FilterByActivity(threshold);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Find location that work the most days in a week
|
||||
/// </summary>
|
||||
/// <returns>Most active location</returns>
|
||||
public Location FindMostActiveLocation()
|
||||
{
|
||||
if (AllLocations.Count == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
Location mostActive = AllLocations.Get(0);
|
||||
for (int i = 0; i < AllLocations.Count; i++)
|
||||
{
|
||||
Location location = AllLocations.Get(i);
|
||||
if (location.Workdays.Count > mostActive.Workdays.Count)
|
||||
{
|
||||
mostActive = location;
|
||||
}
|
||||
}
|
||||
return mostActive;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Find all locations that work the most days in a week
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public LocationsContainer FindMostActiveLocations()
|
||||
{
|
||||
Location mostActive = FindMostActiveLocation();
|
||||
LocationsContainer activeLocations = new LocationsContainer();
|
||||
for (int i = 0; i < AllLocations.Count; i++)
|
||||
{
|
||||
Location location = AllLocations.Get(i);
|
||||
if (location.Workdays.Count == mostActive.Workdays.Count)
|
||||
{
|
||||
activeLocations.Add(location);
|
||||
}
|
||||
}
|
||||
return activeLocations;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Filter by property "Type".
|
||||
/// </summary>
|
||||
/// <param name="type">Target type</param>
|
||||
/// <returns>A filtered container of locations</returns>
|
||||
public LocationsContainer FilterByType(string type)
|
||||
{
|
||||
return AllLocations.FilterByType(type);
|
||||
}
|
||||
|
||||
private List<string> GetLocationNames()
|
||||
{
|
||||
List<string> result = new List<string>();
|
||||
for (int i = 0; i < AllLocations.Count; i++)
|
||||
{
|
||||
Location location = AllLocations.Get(i);
|
||||
if (!result.Contains(location.Name))
|
||||
{
|
||||
result.Add(location.Name);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Find all locations that have matching names
|
||||
/// </summary>
|
||||
/// <returns>A container with locations that have matching names</returns>
|
||||
public LocationsContainer FindLocationsWithDuplicateNames()
|
||||
{
|
||||
LocationsContainer result = new LocationsContainer();
|
||||
List<string> names = GetLocationNames();
|
||||
foreach (string name in names)
|
||||
{
|
||||
LocationsContainer locationsByName = AllLocations.FilterByName(name);
|
||||
if (locationsByName.Count <= 1) continue;
|
||||
|
||||
for (int i = 0; i < locationsByName.Count; i++)
|
||||
{
|
||||
result.Add(locationsByName.Get(i));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ namespace Lab5.TouristInformationCenter
|
||||
public string Author { get; set; }
|
||||
public string MonumentName { get; set; }
|
||||
|
||||
public Statue(string name, string city, string address, int year, string manager, string author, string monumentName) : base(name, city, address, year, manager)
|
||||
public Statue(string city, string manager, string name, string address, int year, string author, string monumentName) : base(city, manager, name, address, year)
|
||||
{
|
||||
Author = author;
|
||||
MonumentName = monumentName;
|
||||
|
Loading…
Reference in New Issue
Block a user