diff --git a/Lab1 b/Lab1 deleted file mode 160000 index a5b10c3..0000000 --- a/Lab1 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a5b10c3cb82eaf1e6871ed9f56aed23759466c9c diff --git a/Lab1/Lab1.Exercises.Register/Dog.cs b/Lab1/Lab1.Exercises.Register/Dog.cs new file mode 100644 index 0000000..a68eae1 --- /dev/null +++ b/Lab1/Lab1.Exercises.Register/Dog.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Lab1.Exercises.Register +{ + class Dog + { + public int ID { get; set; } + public string Name { get; set; } + public string Breed { get; set; } + public DateTime BirthDate { get; set; } + public Gender Gender { get; set; } + public Dog(int id, string name, string breed, DateTime birthDate, Gender gender) + { + ID = id; + Name = name; + Breed = breed; + BirthDate = birthDate; + Gender = gender; + } + public int CalculateAge() + { + DateTime today = DateTime.Today; + int age = today.Year - BirthDate.Year; + if (BirthDate.Date > today.AddYears(-age)) + { + age--; + } + return age; + } + } +} diff --git a/Lab1/Lab1.Exercises.Register/Dogs.csv b/Lab1/Lab1.Exercises.Register/Dogs.csv new file mode 100644 index 0000000..f9070b5 --- /dev/null +++ b/Lab1/Lab1.Exercises.Register/Dogs.csv @@ -0,0 +1,6 @@ +123;Reksas;Buldogas;2014-01-01;Male +124;Margis;Dalmantinas;2014-02-28;Male +125;Bitė;Senbernaras;2008-07-17;Female +320;Rikis;Taksas;2012-01-07;Male +415;Pifas;Taksas;2014-07-07;Male +420;Markas;Dalmantinas;2013-02-28;Female \ No newline at end of file diff --git a/Lab1/Lab1.Exercises.Register/Gender.cs b/Lab1/Lab1.Exercises.Register/Gender.cs new file mode 100644 index 0000000..3725214 --- /dev/null +++ b/Lab1/Lab1.Exercises.Register/Gender.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Lab1.Exercises.Register +{ + enum Gender + { + Male = 1, + Female = 2, + } +} diff --git a/Lab1/Lab1.Exercises.Register/InOutUtils.cs b/Lab1/Lab1.Exercises.Register/InOutUtils.cs new file mode 100644 index 0000000..3be9e02 --- /dev/null +++ b/Lab1/Lab1.Exercises.Register/InOutUtils.cs @@ -0,0 +1,64 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; + +namespace Lab1.Exercises.Register +{ + class InOutUtils + { + public static List ReadDogs(string fileName) + { + List Dogs = new List(); + string[] Lines = File.ReadAllLines(fileName, Encoding.UTF8); + foreach (string line in Lines) + { + string[] Values = line.Split(';'); + int id = int.Parse(Values[0]); + string name = Values[1]; + string breed = Values[2]; + DateTime birthDate = DateTime.Parse(Values[3]); + Gender gender; + Enum.TryParse(Values[4], out gender); //tries to convert value to enum + Dog dog = new Dog(id, name, breed, birthDate, gender); + Dogs.Add(dog); + } + return Dogs; + } + public static void PrintDogs(List Dogs) + { + Console.WriteLine(new string('-', 74)); + Console.WriteLine("| {0,8} | {1,-15} | {2,-15} | {3,-12} | {4,-8} |", "Reg.Nr.", "Vardas", "Veislė", "Gimimo data", "Lytis"); + Console.WriteLine(new string('-', 74)); + foreach (Dog dog in Dogs) + { + Console.WriteLine("| {0,8} | {1,-15} | {2,-15} | {3,-12:yyyy-MM-dd} | {4,-8} |", dog.ID, dog.Name, dog.Breed, dog.BirthDate, dog.Gender); + } + Console.WriteLine(new string('-', 74)); + } + + public static void PrintDog(Dog dog) + { + Console.WriteLine("Vardas: {0}, Veislė: {1}, Amžius: {2}", dog.Name, dog.Breed, dog.CalculateAge()); + } + + public static void PrintBreeds(List breeds) + { + foreach (string breed in breeds) + { + Console.WriteLine(breed); + } + } + + public static void PrintDogsToCSVFile(string fileName, List Dogs) + { + string[] lines = new string[Dogs.Count + 1]; + lines[0] = String.Format("{0};{1};{2};{3};{4}", "Reg.Nr.", "Vardas", "Veislė", "Gimimo data", "Lytis"); + for (int i = 0; i < Dogs.Count; i++) + { + lines[i + 1] = String.Format("{0};{1};{2};{3};{4}", Dogs[i].ID, Dogs[i].Name, Dogs[i].Breed, Dogs[i].BirthDate, Dogs[i].Gender); + } + File.WriteAllLines(fileName, lines, Encoding.UTF8); + } + } +} diff --git a/Lab1/Lab1.Exercises.Register/Lab1.Exercises.Register.csproj b/Lab1/Lab1.Exercises.Register/Lab1.Exercises.Register.csproj new file mode 100644 index 0000000..2e6dfb4 --- /dev/null +++ b/Lab1/Lab1.Exercises.Register/Lab1.Exercises.Register.csproj @@ -0,0 +1,14 @@ + + + + Exe + netcoreapp2.1 + + + + + PreserveNewest + + + + diff --git a/Lab1/Lab1.Exercises.Register/Program.cs b/Lab1/Lab1.Exercises.Register/Program.cs new file mode 100644 index 0000000..219ef12 --- /dev/null +++ b/Lab1/Lab1.Exercises.Register/Program.cs @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; + +namespace Lab1.Exercises.Register +{ + class Program + { + static void Main(string[] args) + { + List allDogs = InOutUtils.ReadDogs("Dogs.csv"); + Console.WriteLine("Registro informacija:"); + InOutUtils.PrintDogs(allDogs); + + Console.WriteLine("Iš viso šunų: {0}", allDogs.Count); + Console.WriteLine("Patinų: {0}", TaskUtils.CountByGender(allDogs, Gender.Male)); + Console.WriteLine("Patelių: {0}", TaskUtils.CountByGender(allDogs, Gender.Female)); + Console.WriteLine(); + + Dog oldestDog = TaskUtils.FindOldestDog(allDogs); + Console.WriteLine("Seniausias šuo:"); + InOutUtils.PrintDog(oldestDog); + Console.WriteLine(); + + List breeds = TaskUtils.FindBreeds(allDogs); + Console.WriteLine("Šunų veislės:"); + InOutUtils.PrintBreeds(breeds); + Console.WriteLine(); + + List popularBreeds = TaskUtils.FindMostPopularBreeds(allDogs); + Console.WriteLine("Populiariausios šunų veislės:"); + InOutUtils.PrintBreeds(popularBreeds); + Console.WriteLine(); + + Console.WriteLine("Kokios veislės šunis atrinkti?"); + string selectedBreed = Console.ReadLine().Trim(); + if (selectedBreed.Equals("")) + { + Console.WriteLine("Šunio veislė neįvesta"); + return; + } + + List filteredByBreed = TaskUtils.FilterByBreed(allDogs, selectedBreed); + if (filteredByBreed.Count == 0) + { + Console.WriteLine("Šunų su veisle '{0}' nerasta", selectedBreed); + return; + } + + Dog oldestFilteredDog = TaskUtils.FindOldestDog(filteredByBreed); + Console.WriteLine("Seniausias šuo pagal '{0}' veislę:", selectedBreed); + InOutUtils.PrintDog(oldestFilteredDog); + InOutUtils.PrintDogs(filteredByBreed); + string fileName = selectedBreed + ".csv"; + InOutUtils.PrintDogsToCSVFile(fileName, filteredByBreed); + + } + } +} diff --git a/Lab1/Lab1.Exercises.Register/TaskUtils.cs b/Lab1/Lab1.Exercises.Register/TaskUtils.cs new file mode 100644 index 0000000..befb030 --- /dev/null +++ b/Lab1/Lab1.Exercises.Register/TaskUtils.cs @@ -0,0 +1,99 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Lab1.Exercises.Register +{ + class TaskUtils + { + public static int CountByGender(List dogs, Gender gender) + { + int count = 0; + foreach (Dog dog in dogs) + { + if (dog.Gender.Equals(gender)) + { + count++; + } + } + return count; + } + public static Dog FindOldestDog(List dogs) + { + Dog oldest = dogs[0]; // means least value + for (int i = 1; i < dogs.Count; i++) + { + if (DateTime.Compare(dogs[i].BirthDate, oldest.BirthDate) < 0) + { + oldest = dogs[i]; + } + } + return oldest; + } + public static List FindBreeds(List dogs) + { + List Breeds = new List(); + foreach (Dog dog in dogs) + { + string breed = dog.Breed; + if (!Breeds.Contains(breed)) // uses List method Contains() + { + Breeds.Add(breed); + } + } + return Breeds; + } + + public static List FilterByBreed(List dogs, string breed) + { + List Filtered = new List(); + foreach (Dog dog in dogs) + { + if (dog.Breed.Equals(breed)) // uses string method Equals() + { + Filtered.Add(dog); + } + } + return Filtered; + } + + public static int CountByBreed(List dogs, string breed) + { + int count = 0; + foreach (Dog dog in dogs) + { + if (dog.Breed.Equals(breed)) // uses string method Equals() + { + count++; + } + } + return count; + } + + public static List FindMostPopularBreeds(List dogs) + { + List breeds = FindBreeds(dogs); + int mostPopularCount = CountByBreed(dogs, breeds[0]); + foreach (string breed in breeds) + { + int count = CountByBreed(dogs, breed); + if (count > mostPopularCount) + { + mostPopularCount = count; + } + } + + List popularBreeds = new List(); + foreach (string breed in breeds) + { + if (CountByBreed(dogs, breed) == mostPopularCount) + { + popularBreeds.Add(breed); + } + } + + return popularBreeds; + } + + } +} diff --git a/Lab1/Lab1.IMDB/Actors.csv b/Lab1/Lab1.IMDB/Actors.csv new file mode 100644 index 0000000..53eb0ad --- /dev/null +++ b/Lab1/Lab1.IMDB/Actors.csv @@ -0,0 +1,5 @@ +T. Cruise +Tiesiog Petras +Kaimynas Rokas +N. Kidman +Tiesiog Jonas diff --git a/Lab1/Lab1.IMDB/InOutUtils.cs b/Lab1/Lab1.IMDB/InOutUtils.cs new file mode 100644 index 0000000..57866cf --- /dev/null +++ b/Lab1/Lab1.IMDB/InOutUtils.cs @@ -0,0 +1,39 @@ +using System.Collections.Generic; +using System.IO; +using System.Text; + +namespace Lab1.IMDB +{ + class InOutUtils + { + public static List ReadMovies(string filename) + { + List movies = new List(); + string[] lines = File.ReadAllLines(filename, Encoding.UTF8); + foreach (string line in lines) + { + string[] values = line.Split(';'); + string title = values[0]; + int year = int.Parse(values[1]); + string genre = values[2]; + string studio = values[3]; + string producer = values[4]; + string actor1 = values[5]; + string actor2 = values[6]; + Movie movie = new Movie(title, year, genre, studio, producer, actor1, actor2); + movies.Add(movie); + } + return movies; + } + + public static void WriteActors(string filename, List actors) + { + string[] lines = new string[actors.Count]; + for (int i = 0; i < actors.Count; i++) + { + lines[i] = actors[i]; + } + File.WriteAllLines(filename, lines, Encoding.UTF8); + } + } +} diff --git a/Lab1/Lab1.IMDB/Lab1.IMDB.csproj b/Lab1/Lab1.IMDB/Lab1.IMDB.csproj new file mode 100644 index 0000000..c32a44f --- /dev/null +++ b/Lab1/Lab1.IMDB/Lab1.IMDB.csproj @@ -0,0 +1,14 @@ + + + + Exe + net461 + + + + + PreserveNewest + + + + diff --git a/Lab1/Lab1.IMDB/Movie.cs b/Lab1/Lab1.IMDB/Movie.cs new file mode 100644 index 0000000..0d0a33c --- /dev/null +++ b/Lab1/Lab1.IMDB/Movie.cs @@ -0,0 +1,24 @@ + +namespace Lab1.IMDB +{ + class Movie + { + public string Title { get; set; } + public int Year { get; set; } + public string Genre { get; set; } + public string Studio { get; set; } + public string Producer { get; set; } + public string Actor1 { get; set; } + public string Actor2 { get; set; } + public Movie(string title, int year, string genre, string studio, string producer, string actor1, string actor2) { + Title = title; + Year = year; + Genre = genre; + Studio = studio; + Producer = producer; + Actor1 = actor1; + Actor2 = actor2; + } + } +} + diff --git a/Lab1/Lab1.IMDB/Movies.csv b/Lab1/Lab1.IMDB/Movies.csv new file mode 100644 index 0000000..503f96e --- /dev/null +++ b/Lab1/Lab1.IMDB/Movies.csv @@ -0,0 +1,7 @@ +MovieA;2020;FooBar;Warner Bros;Jonaitis jonas;T. Cruise;Tiesiog Petras +MovieB;2010;FooBar;Mano Bros;Kaimyne Ona;Tiesiog Petras;Kaimynas Rokas +MovieC;2024;FooBar;Mano Bros;Jonaitis jonas;T. Cruise;Tiesiog Petras +MovieD;1020;FooBar;Warner Bros;Jonaitis jonas;T. Cruise;N. Kidman +MovieE;2012;FooBar;Warner Bros;Jonaitis kasparas;T. Cruise;Tiesiog Petras +MovieF;2110;FooBar;Tavo Bros;Jonaitis petras;Tiesiog Petras;Tiesiog Jonas +MovieG;2120;FooBar;Tavo Bros;Jonaitis jonas;N. Kidman;T. Cruise diff --git a/Lab1/Lab1.IMDB/Program.cs b/Lab1/Lab1.IMDB/Program.cs new file mode 100644 index 0000000..21d6cb4 --- /dev/null +++ b/Lab1/Lab1.IMDB/Program.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; + +// Variant U1-21. +namespace Lab1.IMDB +{ + class Program + { + static void Main(string[] args) + { + List movies = InOutUtils.ReadMovies("Movies.csv"); + + List filteredByActors = TaskUtils.FilterByActors(movies, "T. Cruise", "N. Kidman"); + Console.WriteLine("Movies with T. Cruise and N. Kidman:"); + foreach (Movie movie in filteredByActors) + { + Console.WriteLine("{0} {1}", movie.Title, movie.Year); + } + Console.WriteLine(); + + + List filteredByStudio = TaskUtils.FilterByStudio(movies, "Warner Bros"); + Console.WriteLine("Movies by Warner Bros:"); + foreach (Movie movie in filteredByStudio) + { + Console.WriteLine("{0} {1}", movie.Title, movie.Year); + } + + List actors = TaskUtils.GetActors(movies); + InOutUtils.WriteActors("Actors.csv", actors); + } + } +} diff --git a/Lab1/Lab1.IMDB/TaskUtils.cs b/Lab1/Lab1.IMDB/TaskUtils.cs new file mode 100644 index 0000000..59e9c44 --- /dev/null +++ b/Lab1/Lab1.IMDB/TaskUtils.cs @@ -0,0 +1,51 @@ +using System.Collections.Generic; +using System; + +namespace Lab1.IMDB +{ + class TaskUtils + { + public static List FilterByActors(List movies, string actor1, string actor2) + { + List filtered = new List(); + foreach (Movie movie in movies) + { + if (movie.Actor1 == actor1 && movie.Actor2 == actor2 || movie.Actor1 == actor2 && movie.Actor2 == actor1) + { + filtered.Add(movie); + } + } + return filtered; + } + + public static List FilterByStudio(List movies, string studio) + { + List filtered = new List(); + foreach (Movie movie in movies) + { + if (movie.Studio.Equals(studio)) + { + filtered.Add(movie); + } + } + return filtered; + } + + public static List GetActors(List movies) + { + List actors = new List(); + foreach (Movie movie in movies) + { + if (!actors.Contains(movie.Actor1)) + { + actors.Add(movie.Actor1); + } + if (!actors.Contains(movie.Actor2)) + { + actors.Add(movie.Actor2); + } + } + return actors; + } + } +} diff --git a/Lab1/Lab1.TouristInformationCenter/InOutUtils.cs b/Lab1/Lab1.TouristInformationCenter/InOutUtils.cs new file mode 100644 index 0000000..5c975b7 --- /dev/null +++ b/Lab1/Lab1.TouristInformationCenter/InOutUtils.cs @@ -0,0 +1,113 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.IO; + +namespace Lab1.TouristInformationCenter +{ + /// + /// Class that stores functions that are related to reading and writing data + /// + class InOutUtils + { + /// + /// Read and decode a list of museums from a file. The file must be in a csv format using ";" as seperators. + /// + /// Target file + /// List of museums + public static List ReadMuseums(string filename) + { + List museums = new List(); + string[] lines = File.ReadAllLines(filename, Encoding.UTF8); + foreach (string line in lines) + { + string[] values = line.Split(';'); + string name = values[0]; + string city = values[1]; + string type = values[2]; + List workdays = new List(); + if (int.Parse(values[3]) == 1) + { + workdays.Add(Weekday.Monday); + } + if (int.Parse(values[4]) == 1) + { + workdays.Add(Weekday.Tuesday); + } + if (int.Parse(values[5]) == 1) + { + workdays.Add(Weekday.Wednesday); + } + if (int.Parse(values[6]) == 1) + { + workdays.Add(Weekday.Thursday); + } + if (int.Parse(values[7]) == 1) + { + workdays.Add(Weekday.Friday); + } + if (int.Parse(values[8]) == 1) + { + workdays.Add(Weekday.Saturday); + } + if (int.Parse(values[9]) == 1) + { + workdays.Add(Weekday.Sunday); + } + double price = double.Parse(values[10]); + bool hasGuide = int.Parse(values[11]) == 1; + + Museum museum = new Museum(name, city, type, workdays, price, hasGuide); + museums.Add(museum); + } + return museums; + } + + /// + /// Write and encodes a list of museums to a file. The file will be in a csv format using ";" as seperators. + /// + /// Target file + /// List of museums + public static void WriteMuseums(string filename, List museums) + { + string[] lines = new string[museums.Count]; + for (int i = 0; i < museums.Count; i++) + { + Museum m = museums[i]; + 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"; + + lines[i] = String.Join(";", m.Name, m.City, m.Type, workDays, m.Price, m.HasGuide ? '1' : '0'); + } + File.WriteAllLines(filename, lines, Encoding.UTF8); + } + + /// + /// Write out a list of museums in a table to the console. + /// + /// List of museums + public static void PrintMuseums(List museums) + { + if (museums.Count == 0) + { + Console.WriteLine("Nėra"); + return; + } + + Console.WriteLine(new string('-', 100)); + Console.WriteLine("| {0,-20} | {1,-15} | {2,-10} | {3,18} | {4,8} | {5,-4} |", "Vardas", "Miestas", "Tipas", "Darbo dienų kiekis", "Kaina", "Turi gidą?"); + Console.WriteLine(new string('-', 100)); + foreach (Museum m in museums) + { + Console.WriteLine("| {0,-20} | {1,-15} | {2,-10} | {3,18} | {4,8:f2} | {5,-10} |", m.Name, m.City, m.Type, m.Workdays.Count, m.Price, m.HasGuide ? "Taip" : "Ne"); + } + Console.WriteLine(new string('-', 100)); + } + } +} diff --git a/Lab1/Lab1.TouristInformationCenter/Lab1.TouristInformationCenter.csproj b/Lab1/Lab1.TouristInformationCenter/Lab1.TouristInformationCenter.csproj new file mode 100644 index 0000000..11d201f --- /dev/null +++ b/Lab1/Lab1.TouristInformationCenter/Lab1.TouristInformationCenter.csproj @@ -0,0 +1,14 @@ + + + + Exe + netcoreapp2.1 + + + + + PreserveNewest + + + + diff --git a/Lab1/Lab1.TouristInformationCenter/Museum.cs b/Lab1/Lab1.TouristInformationCenter/Museum.cs new file mode 100644 index 0000000..eec083a --- /dev/null +++ b/Lab1/Lab1.TouristInformationCenter/Museum.cs @@ -0,0 +1,26 @@ +using System.Collections.Generic; + +namespace Lab1.TouristInformationCenter +{ + /// + /// Class used for storing data related a single museum. + /// + class Museum + { + public string Name { get; set; } + public string City { get; set; } + public string Type { get; set; } + public List Workdays { get; set; } + public double Price { get; set; } + public bool HasGuide { get; set; } + public Museum(string name, string city, string type, List workdays, double price, bool hasGuide) + { + Name = name; + City = city; + Type = type; + Workdays = workdays; + Price = price; + HasGuide = hasGuide; + } + } +} diff --git a/Lab1/Lab1.TouristInformationCenter/Museums.csv b/Lab1/Lab1.TouristInformationCenter/Museums.csv new file mode 100644 index 0000000..684dff6 --- /dev/null +++ b/Lab1/Lab1.TouristInformationCenter/Museums.csv @@ -0,0 +1,6 @@ +VilnausMuziejus;Vilnius;History;1;1;0;1;1;0;0;5,49;0 +KaunoMuziejus;Kaunas;Computer;1;1;0;1;1;1;1;4,69;1 +ŠiauliųMuziejus;Šiauliai;History;0;1;1;1;1;0;0;1,23;1 +MarijampolėsMuziejus;Marijampolė;Food;1;1;1;1;1;1;1;6,90;1 +AlytausMuziejus;Alytus;History;0;1;0;1;1;0;1;10,49;0 +KlaipėdosMuziejus;Klaipėda;Space;1;1;0;1;0;0;0;1,00;0 \ No newline at end of file diff --git a/Lab1/Lab1.TouristInformationCenter/Program.cs b/Lab1/Lab1.TouristInformationCenter/Program.cs new file mode 100644 index 0000000..d528e8e --- /dev/null +++ b/Lab1/Lab1.TouristInformationCenter/Program.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; + +namespace Lab1.TouristInformationCenter +{ + class Program + { + static void Main(string[] args) + { + // Read all museums from initial data file. + List museums = InOutUtils.ReadMuseums("Museums.csv"); + Console.WriteLine("Visi muziejai:"); + InOutUtils.PrintMuseums(museums); + Console.WriteLine(); + + // Filter out museums that are free and a guide. And output those museums to the console. + Console.WriteLine("Muziejai kurie yra nemokami ir turi gidą:"); + InOutUtils.PrintMuseums(TaskUtils.FilterByFreeAndWithGuide(museums)); + Console.WriteLine(); + + // Filter out museums that are "active". And output those museums to the console. + Console.WriteLine("Muziejai kurie dirba bent 5 kartus per savaitę:"); + InOutUtils.PrintMuseums(TaskUtils.FilterByActiveMuseums(museums)); + Console.WriteLine(); + + // Filter out museums that are from "non-popular" cities. And save them to a file. + InOutUtils.WriteMuseums("Atrinkti.csv", TaskUtils.FilterByNonPopularCity(museums)); + } + } +} diff --git a/Lab1/Lab1.TouristInformationCenter/TaskUtils.cs b/Lab1/Lab1.TouristInformationCenter/TaskUtils.cs new file mode 100644 index 0000000..981ef6a --- /dev/null +++ b/Lab1/Lab1.TouristInformationCenter/TaskUtils.cs @@ -0,0 +1,66 @@ +using System.Collections.Generic; + +namespace Lab1.TouristInformationCenter +{ + /// + /// Class used for storing functions that manipulate or filter data. + /// + class TaskUtils + { + /// + /// Return a sub-list of given museums where all museums in the returned list are free and have a guide. + /// + /// List of museums + /// Filtered sub-list of museums + public static List FilterByFreeAndWithGuide(List museums) + { + List filtered = new List(); + foreach (Museum museum in museums) + { + if (museum.HasGuide && museum.Price == 0) + { + filtered.Add(museum); + } + } + return filtered; + } + + /// + /// Return a sub-list of given museums where all museums in the returned list are "active". + /// A museum is considered active if it is working at least 5 times a week. + /// + /// List of museums + /// Filtered sub-list of museums + public static List FilterByActiveMuseums(List museums) + { + List filtered = new List(); + foreach (Museum museum in museums) + { + if (museum.Workdays.Count >= 5) + { + filtered.Add(museum); + } + } + return filtered; + } + + /// + /// Return a sub-list of given museums where all museums in the returned list are from "non-popular" cities. + /// A city is "non-popular" if it is not "Vilnius", "Kaunas" or "Klaipėda". + /// + /// List of museums + /// Filtered sub-list of museums + public static List FilterByNonPopularCity(List museums) + { + List filtered = new List(); + foreach (Museum museum in museums) + { + if (!(museum.City.Equals("Vilnius") || museum.City.Equals("Kaunas") || museum.City.Equals("Klaipėda"))) + { + filtered.Add(museum); + } + } + return filtered; + } + } +} diff --git a/Lab1/Lab1.TouristInformationCenter/Weekday.cs b/Lab1/Lab1.TouristInformationCenter/Weekday.cs new file mode 100644 index 0000000..59c6ee9 --- /dev/null +++ b/Lab1/Lab1.TouristInformationCenter/Weekday.cs @@ -0,0 +1,17 @@ + +namespace Lab1.TouristInformationCenter +{ + /// + /// Used for storing weekdays as numbers rather than strings + /// + enum Weekday + { + Monday = 1, + Tuesday = 2, + Wednesday = 3, + Thursday = 4, + Friday = 5, + Saturday = 6, + Sunday = 7 + } +} diff --git a/Lab1/Lab1.TouristInformationCenter/tests/1/Museums.csv b/Lab1/Lab1.TouristInformationCenter/tests/1/Museums.csv new file mode 100644 index 0000000..308e5fa --- /dev/null +++ b/Lab1/Lab1.TouristInformationCenter/tests/1/Museums.csv @@ -0,0 +1,7 @@ +MusuemA;Vilnius;History;1;1;0;1;1;0;0;5,49;0 +MusuemB;Kaunas;Computer;1;1;0;0;1;1;1;4,20;1 +MusuemC;Šiauliai;History;0;1;1;1;1;0;0;0,00;1 +MusuemD;Marijampolė;Food;1;12;1;1;1;1;1;6,90;1 +MusuemE;Alytus;History;0;1;0;1;1;1;1;10,49;0 +MusuemF;Kaimas;History;1;1;1;1;0;1;1;0,00;1 +MusuemG;Klaipėda;Space;1;1;1;1;0;0;0;0,00;0 diff --git a/Lab1/Lab1.TouristInformationCenter/tests/2/Museums.csv b/Lab1/Lab1.TouristInformationCenter/tests/2/Museums.csv new file mode 100644 index 0000000..1bc0bad --- /dev/null +++ b/Lab1/Lab1.TouristInformationCenter/tests/2/Museums.csv @@ -0,0 +1,6 @@ +VilnausMuziejus;Vilnius;History;1;1;0;1;1;0;0;5,49;0 +KaunoMuziejus;Kaunas;Computer;1;1;0;1;1;1;1;4,69;1 +ŠiauliųMuziejus;Šiauliai;History;0;1;1;1;1;0;0;1,23;1 +MarijampolėsMuziejus;Marijampolė;Food;1;1;1;1;1;1;1;6,90;1 +AlytausMuziejus;Alytus;History;0;1;0;1;1;0;1;10,49;0 +KlaipėdosMuziejus;Klaipėda;Space;1;1;0;1;0;0;0;1,00;0 diff --git a/Lab1/Lab1.sln b/Lab1/Lab1.sln new file mode 100644 index 0000000..782ff1c --- /dev/null +++ b/Lab1/Lab1.sln @@ -0,0 +1,79 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28307.1525 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "1Savarankiskas", "Lab1.1Savarankiskas\1Savarankiskas.csproj", "{D07BFD15-69E6-4D59-866D-CEB9730B1DF5}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lab1.Exercises.Register", "Lab1.Exercises.Register\Lab1.Exercises.Register.csproj", "{2EEB9341-1B3B-41F0-B22A-762984B255B0}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lab1.IMDB", "Lab1.IMDB\Lab1.IMDB.csproj", "{FA4EC695-560B-43F8-A864-ADC843A91D65}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lab1.TouristInformationCenter", "Lab1.TouristInformationCenter\Lab1.TouristInformationCenter.csproj", "{7E583A11-4139-40AA-89C6-E5CAE0F27AD5}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D07BFD15-69E6-4D59-866D-CEB9730B1DF5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D07BFD15-69E6-4D59-866D-CEB9730B1DF5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D07BFD15-69E6-4D59-866D-CEB9730B1DF5}.Debug|x64.ActiveCfg = Debug|Any CPU + {D07BFD15-69E6-4D59-866D-CEB9730B1DF5}.Debug|x64.Build.0 = Debug|Any CPU + {D07BFD15-69E6-4D59-866D-CEB9730B1DF5}.Debug|x86.ActiveCfg = Debug|Any CPU + {D07BFD15-69E6-4D59-866D-CEB9730B1DF5}.Debug|x86.Build.0 = Debug|Any CPU + {D07BFD15-69E6-4D59-866D-CEB9730B1DF5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D07BFD15-69E6-4D59-866D-CEB9730B1DF5}.Release|Any CPU.Build.0 = Release|Any CPU + {D07BFD15-69E6-4D59-866D-CEB9730B1DF5}.Release|x64.ActiveCfg = Release|Any CPU + {D07BFD15-69E6-4D59-866D-CEB9730B1DF5}.Release|x64.Build.0 = Release|Any CPU + {D07BFD15-69E6-4D59-866D-CEB9730B1DF5}.Release|x86.ActiveCfg = Release|Any CPU + {D07BFD15-69E6-4D59-866D-CEB9730B1DF5}.Release|x86.Build.0 = Release|Any CPU + {2EEB9341-1B3B-41F0-B22A-762984B255B0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2EEB9341-1B3B-41F0-B22A-762984B255B0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2EEB9341-1B3B-41F0-B22A-762984B255B0}.Debug|x64.ActiveCfg = Debug|Any CPU + {2EEB9341-1B3B-41F0-B22A-762984B255B0}.Debug|x64.Build.0 = Debug|Any CPU + {2EEB9341-1B3B-41F0-B22A-762984B255B0}.Debug|x86.ActiveCfg = Debug|Any CPU + {2EEB9341-1B3B-41F0-B22A-762984B255B0}.Debug|x86.Build.0 = Debug|Any CPU + {2EEB9341-1B3B-41F0-B22A-762984B255B0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2EEB9341-1B3B-41F0-B22A-762984B255B0}.Release|Any CPU.Build.0 = Release|Any CPU + {2EEB9341-1B3B-41F0-B22A-762984B255B0}.Release|x64.ActiveCfg = Release|Any CPU + {2EEB9341-1B3B-41F0-B22A-762984B255B0}.Release|x64.Build.0 = Release|Any CPU + {2EEB9341-1B3B-41F0-B22A-762984B255B0}.Release|x86.ActiveCfg = Release|Any CPU + {2EEB9341-1B3B-41F0-B22A-762984B255B0}.Release|x86.Build.0 = Release|Any CPU + {FA4EC695-560B-43F8-A864-ADC843A91D65}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FA4EC695-560B-43F8-A864-ADC843A91D65}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FA4EC695-560B-43F8-A864-ADC843A91D65}.Debug|x64.ActiveCfg = Debug|Any CPU + {FA4EC695-560B-43F8-A864-ADC843A91D65}.Debug|x64.Build.0 = Debug|Any CPU + {FA4EC695-560B-43F8-A864-ADC843A91D65}.Debug|x86.ActiveCfg = Debug|Any CPU + {FA4EC695-560B-43F8-A864-ADC843A91D65}.Debug|x86.Build.0 = Debug|Any CPU + {FA4EC695-560B-43F8-A864-ADC843A91D65}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FA4EC695-560B-43F8-A864-ADC843A91D65}.Release|Any CPU.Build.0 = Release|Any CPU + {FA4EC695-560B-43F8-A864-ADC843A91D65}.Release|x64.ActiveCfg = Release|Any CPU + {FA4EC695-560B-43F8-A864-ADC843A91D65}.Release|x64.Build.0 = Release|Any CPU + {FA4EC695-560B-43F8-A864-ADC843A91D65}.Release|x86.ActiveCfg = Release|Any CPU + {FA4EC695-560B-43F8-A864-ADC843A91D65}.Release|x86.Build.0 = Release|Any CPU + {7E583A11-4139-40AA-89C6-E5CAE0F27AD5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7E583A11-4139-40AA-89C6-E5CAE0F27AD5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7E583A11-4139-40AA-89C6-E5CAE0F27AD5}.Debug|x64.ActiveCfg = Debug|Any CPU + {7E583A11-4139-40AA-89C6-E5CAE0F27AD5}.Debug|x64.Build.0 = Debug|Any CPU + {7E583A11-4139-40AA-89C6-E5CAE0F27AD5}.Debug|x86.ActiveCfg = Debug|Any CPU + {7E583A11-4139-40AA-89C6-E5CAE0F27AD5}.Debug|x86.Build.0 = Debug|Any CPU + {7E583A11-4139-40AA-89C6-E5CAE0F27AD5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7E583A11-4139-40AA-89C6-E5CAE0F27AD5}.Release|Any CPU.Build.0 = Release|Any CPU + {7E583A11-4139-40AA-89C6-E5CAE0F27AD5}.Release|x64.ActiveCfg = Release|Any CPU + {7E583A11-4139-40AA-89C6-E5CAE0F27AD5}.Release|x64.Build.0 = Release|Any CPU + {7E583A11-4139-40AA-89C6-E5CAE0F27AD5}.Release|x86.ActiveCfg = Release|Any CPU + {7E583A11-4139-40AA-89C6-E5CAE0F27AD5}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {03AFC156-496A-4000-9EFE-0E6803C9EC9A} + EndGlobalSection +EndGlobal diff --git a/Lab1/README.md b/Lab1/README.md new file mode 100644 index 0000000..baae3e9 --- /dev/null +++ b/Lab1/README.md @@ -0,0 +1,6 @@ +# Lab1 example project + +This project is from the "Object oriented programming" course in KTU. + +It is not polished in any way, so don't expect anything from this. + diff --git a/Lab1/global.json b/Lab1/global.json new file mode 100644 index 0000000..4aa91ae --- /dev/null +++ b/Lab1/global.json @@ -0,0 +1,5 @@ +{ + "sdk": { + "version": "3.0.103" + } +}