diff --git a/L3/L3.sln b/L3/L3.sln
new file mode 100644
index 0000000..f0142e3
--- /dev/null
+++ b/L3/L3.sln
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 15
+VisualStudioVersion = 15.0.28307.1525
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LD_24", "LD_24\LD_24.csproj", "{AE159626-A105-440C-B997-F377C5F8F280}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {AE159626-A105-440C-B997-F377C5F8F280}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {AE159626-A105-440C-B997-F377C5F8F280}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {AE159626-A105-440C-B997-F377C5F8F280}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {AE159626-A105-440C-B997-F377C5F8F280}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {7FD3C4E6-8783-4879-9224-302DA8542DAF}
+ EndGlobalSection
+EndGlobal
diff --git a/L3/LD_24/App_Data/Rezultatai.txt b/L3/LD_24/App_Data/Rezultatai.txt
new file mode 100644
index 0000000..8b0f319
--- /dev/null
+++ b/L3/LD_24/App_Data/Rezultatai.txt
@@ -0,0 +1,55 @@
+----------------------------
+| Įtaisai |
+----------------------------
+| ID | Vardas | Kaina |
+----------------------------
+| 0 | Atsuktuvas | 0,99 |
+| 1 | Varztas | 0,05 |
+| 2 | Laidas | 2,00 |
+| 3 | Plaktukas | 2,99 |
+----------------------------
+
+--------------------------------------------------
+| Pirkėjai |
+--------------------------------------------------
+| Pavardė | Vardas | Įtaisas | Įtaiso kiekis |
+--------------------------------------------------
+| Petraitis | Petras | 0 | 10 |
+| Petraitis | Petras | 1 | 10 |
+| Jonaitis | Jonas | 1 | 20 |
+| Jonaitis | Jonas | 1 | 20 |
+| Jonaitis | Jonas | 1 | 20 |
+| Onaite | Ona | 2 | 200 |
+| Jonaitis | Brolis | 1 | 100 |
+| Jonaitis | Brolis | 0 | 100 |
+| Jonaitis | Jonas | 1 | 20 |
+| Jonaitis | Jonas | 1 | 20 |
+| Jonaitis | Jonas | 2 | 20 |
+| Onaite | Ona | 0 | 20 |
+--------------------------------------------------
+
+------------------------------------------------------------
+| Populiariausi įtaisai |
+------------------------------------------------------------
+| ID | Vardas | Įtaisų kiekis, vnt. | Įtaisų kaina, eur. |
+------------------------------------------------------------
+| 2 | Laidas | 220 | 440,00 |
+------------------------------------------------------------
+
+----------------------------------------------------------
+| Vienos rūšies pirkėjai |
+----------------------------------------------------------
+| Pavardė | Vardas | Įtaiso kiekis, vnt. | Kaina, eur. |
+----------------------------------------------------------
+| Nėra |
+----------------------------------------------------------
+
+----------------------------------
+| Atrinkti įtaisai (n=1, k=1,00) |
+----------------------------------
+| ID | Vardas | Kaina |
+----------------------------------
+| 0 | Atsuktuvas | 0,99 |
+| 1 | Varztas | 0,05 |
+----------------------------------
+
diff --git a/L3/LD_24/App_Data/U24a.txt b/L3/LD_24/App_Data/U24a.txt
new file mode 100644
index 0000000..084097c
--- /dev/null
+++ b/L3/LD_24/App_Data/U24a.txt
@@ -0,0 +1,4 @@
+0, Atsuktuvas, 0.99
+1, Varztas, 0.05
+2, Laidas, 2.00
+3, Plaktukas, 2.99
\ No newline at end of file
diff --git a/L3/LD_24/App_Data/U24b.txt b/L3/LD_24/App_Data/U24b.txt
new file mode 100644
index 0000000..22a3639
--- /dev/null
+++ b/L3/LD_24/App_Data/U24b.txt
@@ -0,0 +1,12 @@
+Petraitis, Petras, 0, 10
+Petraitis, Petras, 1, 10
+Jonaitis, Jonas, 1, 20
+Jonaitis, Jonas, 1, 20
+Jonaitis, Jonas, 1, 20
+Onaite, Ona, 2, 200
+Jonaitis, Brolis, 1, 100
+Jonaitis, Brolis, 0, 100
+Jonaitis, Jonas, 1, 20
+Jonaitis, Jonas, 1, 20
+Jonaitis, Jonas, 2, 20
+Onaite, Ona, 0, 20
\ No newline at end of file
diff --git a/L3/LD_24/Code/InOutUtils.cs b/L3/LD_24/Code/InOutUtils.cs
new file mode 100644
index 0000000..adab74b
--- /dev/null
+++ b/L3/LD_24/Code/InOutUtils.cs
@@ -0,0 +1,244 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using System.Web;
+
+namespace LD_24.Code
+{
+ ///
+ /// Class used for reading and writing to files
+ ///
+ public static class InOutUtils
+ {
+ ///
+ /// Read lines from a file
+ ///
+ /// Target filename
+ /// IEnumerable of all the lines
+ private static IEnumerable ReadLines(string filename)
+ {
+ using (StreamReader reader = File.OpenText(filename))
+ {
+ string line;
+ while ((line = reader.ReadLine()) != null)
+ {
+ yield return line;
+ }
+ }
+ }
+
+ ///
+ /// Read products from a file
+ ///
+ /// Target file
+ /// A list of products
+ public static ProductList ReadProducts(string filename)
+ {
+ ProductList products = new ProductList();
+ foreach (string line in ReadLines(filename))
+ {
+ string[] parts = line.Split(',');
+ string id = parts[0].Trim();
+ string name = parts[1].Trim();
+ decimal price = decimal.Parse(parts[2].Trim(), CultureInfo.InvariantCulture);
+ products.AddToEnd(new Product(id, name, price));
+ }
+ return products;
+ }
+
+ ///
+ /// Read orders from a file
+ ///
+ /// Target file
+ /// A list of orders
+ public static OrderList ReadOrders(string filename)
+ {
+ OrderList orders = new OrderList();
+ foreach (string line in ReadLines(filename))
+ {
+ string[] parts = line.Split(',');
+ string customerSurname = parts[0].Trim();
+ string customerName = parts[1].Trim();
+ string productID = parts[2].Trim();
+ int productAmount = int.Parse(parts[3].Trim());
+ orders.AddToEnd(new Order(customerSurname, customerName, productID, productAmount));
+ }
+ return orders;
+ }
+
+ ///
+ /// Print a single table row to file
+ ///
+ /// Target file
+ /// Cell data
+ /// Cell widths
+ private static void PrintTableRow(StreamWriter writer, List cells, List widths)
+ {
+ for (int i = 0; i < widths.Count; i++)
+ {
+ if (widths[i] < 0)
+ writer.Write("| {0} ", cells[i].PadRight(-widths[i]));
+ else
+ writer.Write("| {0} ", cells[i].PadLeft(widths[i]));
+ }
+ writer.WriteLine("|");
+ }
+
+ ///
+ /// Print a table to a file
+ ///
+ /// Target file
+ /// Header above table
+ /// Target list
+ /// Column names
+ /// A IEnumerable for inserting values for each row
+ private static IEnumerable>> PrintTable(StreamWriter writer, string header, IEnumerable list, params string[] columns)
+ {
+ // 0. Collect all the rows
+ List> rows = new List>();
+ foreach (object item in list)
+ {
+ List row = new List();
+ yield return Tuple.Create(item, row);
+ rows.Add(row);
+ }
+
+ // 1. Determine the width of each column
+ List widths = new List();
+ int totalWidth = 3*(columns.Length - 1);
+ for (int i = 0; i < columns.Length; i++)
+ {
+ int width = columns[i].Length;
+ foreach (var row in rows)
+ {
+ width = Math.Max(row[i].Length, width);
+ }
+ widths.Add(width);
+ totalWidth += width;
+ }
+
+ // If the header is longer than the body, make the last column wider.
+ // So the table is a nice rectangle when output to the file
+ if (header.Length > totalWidth)
+ {
+ widths[widths.Count - 1] += (header.Length - totalWidth);
+ totalWidth = header.Length;
+ }
+
+ totalWidth += 2 * 2;
+
+ // 2. Adjust widths to account for aligning
+ for (int i = 0; i < columns.Length; i++)
+ {
+ if (columns[i][0] == '-')
+ {
+ widths[i] = -widths[i];
+ columns[i] = columns[i].Substring(1);
+ }
+ }
+
+ // 3. Display the table
+ writer.WriteLine(new string('-', totalWidth));
+ writer.WriteLine("| {0} |", header.PadRight(totalWidth - 4));
+ writer.WriteLine(new string('-', totalWidth));
+ PrintTableRow(writer, new List(columns), widths);
+ writer.WriteLine(new string('-', totalWidth));
+ if (rows.Count > 0)
+ {
+ foreach (var row in rows)
+ {
+ PrintTableRow(writer, row, widths);
+ }
+ } else
+ {
+ writer.WriteLine("| {0} |", "Nėra".PadRight(totalWidth - 4));
+ }
+ writer.WriteLine(new string('-', totalWidth));
+
+ writer.WriteLine();
+ }
+
+ ///
+ /// Print orders table to file
+ ///
+ /// Target file
+ /// List of orders
+ /// Header above table
+ public static void PrintOrders(StreamWriter writer, OrderList orders, string header)
+ {
+ foreach (var tuple in PrintTable(writer, header, orders, "Pavardė", "Vardas", "-Įtaisas", "-Įtaiso kiekis"))
+ {
+ Order order = (Order)tuple.Item1;
+ List row = tuple.Item2;
+ row.Add(order.CustomerSurname);
+ row.Add(order.CustomerName);
+ row.Add(order.ProductID);
+ row.Add(order.ProductAmount.ToString());
+ }
+ }
+
+ ///
+ /// Print orders with prices table to file
+ ///
+ /// Target file
+ /// List of orders
+ /// List of products
+ /// Header above table
+ public static void PrintOrdersWithPrices(StreamWriter writer, OrderList orders, ProductList products, string header)
+ {
+ foreach (var tuple in PrintTable(writer, header, orders, "Pavardė", "Vardas", "-Įtaiso kiekis, vnt.", "-Kaina, eur."))
+ {
+ Order order = (Order)tuple.Item1;
+ List row = tuple.Item2;
+ Product product = TaskUtils.FindByID(products, order.ProductID);
+
+ row.Add(order.CustomerSurname);
+ row.Add(order.CustomerName);
+ row.Add(order.ProductAmount.ToString());
+ row.Add(String.Format("{0:f2}", order.ProductAmount * product.Price));
+ }
+ }
+
+ ///
+ /// Print a products table to file
+ ///
+ /// Target file
+ /// List of products
+ /// Header above table
+ public static void PrintProducts(StreamWriter writer, ProductList products, string header)
+ {
+ foreach (var tuple in PrintTable(writer, header, products, "ID", "Vardas", "-Kaina"))
+ {
+ Product product = (Product)tuple.Item1;
+ List row = tuple.Item2;
+ row.Add(product.ID);
+ row.Add(product.Name);
+ row.Add(String.Format("{0:f2}", product.Price));
+ }
+ }
+
+ ///
+ /// Print a table of most popular products to file
+ ///
+ /// Target file
+ /// List of orders
+ /// List of most popular products
+ /// Header above table
+ public static void PrintMostPopularProducts(StreamWriter writer, OrderList orders, ProductList popularProducts, string header)
+ {
+ foreach (var tuple in PrintTable(writer, header, popularProducts, "ID", "Vardas", "-Įtaisų kiekis, vnt.", "-Įtaisų kaina, eur."))
+ {
+ Product product = (Product)tuple.Item1;
+ List row = tuple.Item2;
+ int sales = TaskUtils.CountProductSales(orders, product.ID);
+ row.Add(product.ID);
+ row.Add(product.Name);
+ row.Add(sales.ToString());
+ row.Add(String.Format("{0:f2}", sales * product.Price));
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/L3/LD_24/Code/Order.cs b/L3/LD_24/Code/Order.cs
new file mode 100644
index 0000000..1931ccd
--- /dev/null
+++ b/L3/LD_24/Code/Order.cs
@@ -0,0 +1,77 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+namespace LD_24.Code
+{
+ ///
+ /// Class used for storing a single order
+ ///
+ public class Order
+ {
+ ///
+ /// Surname of customer who ordered
+ ///
+ public string CustomerSurname { get; set; }
+ ///
+ /// Name of customer who ordered
+ ///
+ public string CustomerName { get; set; }
+ ///
+ /// ID of ordered product
+ ///
+ public string ProductID { get; set; }
+ ///
+ /// Amount of ordered products
+ ///
+ public int ProductAmount { get; set; }
+
+ public Order(string customerSurname, string customerName, string productID, int productAmount)
+ {
+ CustomerSurname = customerSurname;
+ CustomerName = customerName;
+ ProductID = productID;
+ ProductAmount = productAmount;
+ }
+
+ public override string ToString()
+ {
+ return String.Format("Order{Name = '{0}'}", CustomerName);
+ }
+
+ public static bool operator <(Order a, Order b)
+ {
+ if (a.ProductAmount > b.ProductAmount)
+ {
+ return true;
+ }
+ else if (a.ProductAmount == b.ProductAmount)
+ {
+ int surnameCompare = a.CustomerSurname.CompareTo(b.CustomerSurname);
+ if (surnameCompare < 0)
+ {
+ return true;
+ }
+ else if (surnameCompare == 0)
+ {
+ return a.CustomerName.CompareTo(b.CustomerName) < 0;
+ }
+ }
+
+ return false;
+ }
+ public static bool operator >(Order a, Order b)
+ {
+ return !(a < b && a == b);
+ }
+ public static bool operator ==(Order a, Order b)
+ {
+ return a.ProductAmount == b.ProductAmount && a.CustomerName == b.CustomerName && a.CustomerSurname == b.CustomerSurname;
+ }
+ public static bool operator !=(Order a, Order b)
+ {
+ return !(a == b);
+ }
+ }
+}
\ No newline at end of file
diff --git a/L3/LD_24/Code/OrderList.cs b/L3/LD_24/Code/OrderList.cs
new file mode 100644
index 0000000..9e04ab2
--- /dev/null
+++ b/L3/LD_24/Code/OrderList.cs
@@ -0,0 +1,125 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+namespace LD_24.Code
+{
+ ///
+ /// Stores a orders in a linked list
+ ///
+ public class OrderList : IEnumerable
+ {
+ class OrderNode
+ {
+ public Order Data { get; set; }
+ public OrderNode Next { get; set; }
+
+ public OrderNode(Order data = null, OrderNode next = null)
+ {
+ Data = data;
+ Next = next;
+ }
+ }
+
+ private OrderNode head;
+ private OrderNode tail;
+
+ ///
+ /// Append a value to the end of the linked list
+ ///
+ ///
+ public void AddToEnd(Order customer)
+ {
+ OrderNode node = new OrderNode(customer);
+ if (tail != null && head != null)
+ {
+ tail.Next = node;
+ tail = node;
+ }
+ else
+ {
+ tail = node;
+ head = node;
+ }
+ }
+
+ ///
+ /// Insert a value to the start of the linked list
+ ///
+ ///
+ public void AddToStart(Order customer)
+ {
+ OrderNode node = new OrderNode(customer);
+ if (tail != null && head != null)
+ {
+ node.Next = head;
+ head = node;
+ }
+ else
+ {
+ tail = node;
+ head = node;
+ }
+ }
+
+ ///
+ /// Get the number of values stored in linked list
+ ///
+ /// A count
+ public int Count()
+ {
+ int count = 0;
+ OrderNode current = head;
+ while (current != null)
+ {
+ current = current.Next;
+ count++;
+ }
+ return count;
+ }
+
+ ///
+ /// Sorts the linked list
+ ///
+ public void Sort()
+ {
+ for (OrderNode nodeA = head; nodeA != null; nodeA = nodeA.Next)
+ {
+ OrderNode min = nodeA;
+ for (OrderNode nodeB = nodeA.Next; nodeB != null; nodeB = nodeB.Next)
+ {
+ if (nodeB.Data < min.Data)
+ {
+ min = nodeB;
+ }
+ }
+
+ Order tmp = nodeA.Data;
+ nodeA.Data = min.Data;
+ min.Data = tmp;
+ }
+ }
+
+ public override string ToString()
+ {
+ return String.Format("OrderList{ Count = '{0}' }", Count());
+ }
+
+ public IEnumerator GetEnumerator()
+ {
+ OrderNode current = head;
+ while (current != null)
+ {
+ yield return current.Data;
+ current = current.Next;
+ }
+ }
+
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return GetEnumerator();
+ }
+ }
+}
\ No newline at end of file
diff --git a/L3/LD_24/Code/Product.cs b/L3/LD_24/Code/Product.cs
new file mode 100644
index 0000000..d2ad1bc
--- /dev/null
+++ b/L3/LD_24/Code/Product.cs
@@ -0,0 +1,38 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+namespace LD_24.Code
+{
+ ///
+ /// Holds informations about a single product
+ ///
+ public class Product
+ {
+ ///
+ /// Identification number of product
+ ///
+ public string ID { get; set; }
+ ///
+ /// Name of product
+ ///
+ public string Name { get; set; }
+ ///
+ /// Price of product
+ ///
+ public decimal Price { get; set; }
+
+ public Product(string iD, string name, decimal price)
+ {
+ ID = iD;
+ Name = name;
+ Price = price;
+ }
+
+ public override string ToString()
+ {
+ return String.Format("Product{ID = '{0}'}", ID);
+ }
+ }
+}
diff --git a/L3/LD_24/Code/ProductList.cs b/L3/LD_24/Code/ProductList.cs
new file mode 100644
index 0000000..db56384
--- /dev/null
+++ b/L3/LD_24/Code/ProductList.cs
@@ -0,0 +1,103 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+namespace LD_24.Code
+{
+ ///
+ /// Stores multiple products in a linked list
+ ///
+ public class ProductList : IEnumerable
+ {
+ class ProductNode
+ {
+ public Product Data { get; set; }
+ public ProductNode Next { get; set; }
+
+ public ProductNode(Product data = null, ProductNode next = null)
+ {
+ Data = data;
+ Next = next;
+ }
+ }
+
+ private ProductNode head;
+ private ProductNode tail;
+
+ ///
+ /// Append a value to the end of the linked list
+ ///
+ ///
+ public void AddToEnd(Product product)
+ {
+ ProductNode node = new ProductNode(product);
+ if (tail != null && head != null)
+ {
+ tail.Next = node;
+ tail = node;
+ }
+ else
+ {
+ tail = node;
+ head = node;
+ }
+ }
+
+ ///
+ /// Inserts a value to the start of the linked list
+ ///
+ ///
+ public void AddToStart(Product product)
+ {
+ ProductNode node = new ProductNode(product);
+ if (tail != null && head != null)
+ {
+ node.Next = head;
+ head = node;
+ }
+ else
+ {
+ tail = node;
+ head = node;
+ }
+ }
+
+ ///
+ /// Get the number of values stored in the linked list
+ ///
+ /// A count
+ public int Count()
+ {
+ int count = 0;
+ ProductNode current = head;
+ while (current != null)
+ {
+ current = current.Next;
+ count++;
+ }
+ return count;
+ }
+
+ public override string ToString()
+ {
+ return String.Format("ProductList{ Count = '{0}' }", Count());
+ }
+
+ public IEnumerator GetEnumerator()
+ {
+ ProductNode current = head;
+ while (current != null)
+ {
+ yield return current.Data;
+ current = current.Next;
+ }
+ }
+
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return GetEnumerator();
+ }
+ }
+}
\ No newline at end of file
diff --git a/L3/LD_24/Code/TaskUtils.cs b/L3/LD_24/Code/TaskUtils.cs
new file mode 100644
index 0000000..41262fe
--- /dev/null
+++ b/L3/LD_24/Code/TaskUtils.cs
@@ -0,0 +1,187 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+namespace LD_24.Code
+{
+ ///
+ /// Various functions for operations on data
+ ///
+ public static class TaskUtils
+ {
+ ///
+ /// Finds the most popular products by the number of sales
+ ///
+ /// List of orders
+ /// List of products ids
+ public static List FindMostPopularProducts(OrderList orders)
+ {
+ Dictionary productSales = new Dictionary();
+ foreach (Order order in orders)
+ {
+ if (!productSales.ContainsKey(order.ProductID))
+ {
+ productSales.Add(order.ProductID, order.ProductAmount);
+ }
+ else
+ {
+ productSales[order.ProductID] += order.ProductAmount;
+ }
+ }
+
+ List mostPopularProducts = new List();
+ int mostPopularCount = 0;
+ foreach (string product in productSales.Keys)
+ {
+ int count = productSales[product];
+ if (count > mostPopularCount)
+ {
+ mostPopularCount = count;
+ mostPopularProducts = new List { product };
+ } else if (count == mostPopularCount)
+ {
+ mostPopularProducts.Add(product);
+ }
+ }
+
+ return mostPopularProducts;
+ }
+
+ ///
+ /// Counts the number of sales of a certain product
+ ///
+ /// List of products
+ /// Target product id
+ /// Sales
+ public static int CountProductSales(OrderList orders, string product)
+ {
+ int sales = 0;
+ foreach (Order order in orders)
+ {
+ if (order.ProductID == product)
+ {
+ sales += order.ProductAmount;
+ }
+ }
+ return sales;
+ }
+
+ ///
+ /// Merge orders which have the same customer name, surname and product id into a single order.
+ ///
+ /// A list of orders
+ /// A list of orders where same orders have been merged
+ public static OrderList MergeOrders(OrderList orders)
+ {
+ Dictionary, Order> ordersByName = new Dictionary, Order>();
+ foreach (var order in orders)
+ {
+ var key = Tuple.Create(order.CustomerSurname, order.CustomerName, order.ProductID);
+ if (ordersByName.ContainsKey(key))
+ {
+ ordersByName[key].ProductAmount += order.ProductAmount;
+ } else
+ {
+ ordersByName.Add(key, new Order(order.CustomerSurname, order.CustomerName, order.ProductID, order.ProductAmount));
+ }
+ }
+
+ OrderList mergedOrders = new OrderList();
+ foreach (var order in ordersByName.Values)
+ {
+ mergedOrders.AddToEnd(order);
+ }
+ return mergedOrders;
+ }
+
+ ///
+ /// Finds a product by it's id
+ ///
+ /// List of products
+ /// Target product id
+ /// The product
+ public static Product FindByID(ProductList products, string id)
+ {
+ foreach (Product product in products)
+ {
+ if (product.ID == id)
+ {
+ return product;
+ }
+ }
+ return null;
+ }
+
+ ///
+ /// Find all products by their ids
+ ///
+ /// List of products
+ /// List of product ids
+ /// List of products
+ public static ProductList FindByID(ProductList products, List ids)
+ {
+ ProductList foundProducts = new ProductList();
+ foreach (string id in ids)
+ {
+ foundProducts.AddToEnd(FindByID(products, id));
+ }
+ return foundProducts;
+ }
+
+ ///
+ /// Filter a list of products by sales and price.
+ ///
+ /// List of products
+ /// List of orders
+ /// Minimmum sales amount
+ /// Max product price
+ /// A list of filtered products
+ public static ProductList FilterByQuantitySoldAndPrice(ProductList products, OrderList orders, int minSold, decimal maxPrice)
+ {
+ ProductList filtered = new ProductList();
+ foreach (Product product in products)
+ {
+ if (product.Price < maxPrice)
+ {
+ int sold = CountProductSales(orders, product.ID);
+ if (sold >= minSold)
+ {
+ filtered.AddToEnd(product);
+ }
+ }
+ }
+ return filtered;
+ }
+
+ ///
+ /// Find all customer which bought only 1 type of product
+ ///
+ /// List of orders
+ /// A list of filtered orders
+ public static OrderList FindCustomerWithSingleProduct(OrderList orders)
+ {
+ Dictionary, OrderList> ordersByCusomer = new Dictionary, OrderList>();
+ foreach (var order in TaskUtils.MergeOrders(orders))
+ {
+ var key = Tuple.Create(order.CustomerName, order.CustomerSurname);
+ if (!ordersByCusomer.ContainsKey(key))
+ {
+ ordersByCusomer.Add(key, new OrderList());
+ }
+ ordersByCusomer[key].AddToEnd(order);
+ }
+
+ OrderList finalList = new OrderList();
+ foreach (var customerOrders in ordersByCusomer.Values)
+ {
+ if (customerOrders.Count() == 1)
+ {
+ finalList.AddToEnd(customerOrders.First());
+ }
+ }
+ return finalList;
+ }
+ }
+}
diff --git a/L3/LD_24/Forma1.aspx b/L3/LD_24/Forma1.aspx
new file mode 100644
index 0000000..6aefcdf
--- /dev/null
+++ b/L3/LD_24/Forma1.aspx
@@ -0,0 +1,47 @@
+<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Forma1.aspx.cs" Inherits="LD_24.Forma1" %>
+
+
+
+
+
+
+
+
+
+
+
diff --git a/L3/LD_24/Forma1.aspx.cs b/L3/LD_24/Forma1.aspx.cs
new file mode 100644
index 0000000..f9ee37a
--- /dev/null
+++ b/L3/LD_24/Forma1.aspx.cs
@@ -0,0 +1,58 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Web;
+using System.Web.UI;
+using System.Web.UI.WebControls;
+using LD_24.Code;
+
+namespace LD_24
+{
+ ///
+ /// Main form
+ ///
+ public partial class Forma1 : System.Web.UI.Page
+ {
+ private const string inputFileA = "App_Data/U24a.txt";
+ private const string inputFileB = "App_Data/U24b.txt";
+ private const string outputFilename = "App_Data/Rezultatai.txt";
+
+ protected void Page_Load(object sender, EventArgs e)
+ {
+ FindControl("ResultsDiv").Visible = false;
+ }
+
+ protected void Button1_Click(object sender, EventArgs e)
+ {
+ int n = int.Parse(TextBox1.Text);
+ decimal k = decimal.Parse(TextBox2.Text);
+
+ FindControl("ResultsDiv").Visible = true;
+
+ ProductList products = InOutUtils.ReadProducts(Server.MapPath(inputFileA));
+ OrderList orders = InOutUtils.ReadOrders(Server.MapPath(inputFileB));
+
+ List mostPopularProductIds = TaskUtils.FindMostPopularProducts(orders);
+ ProductList mostPopularProducts = TaskUtils.FindByID(products, mostPopularProductIds);
+ ProductList filteredProducts = TaskUtils.FilterByQuantitySoldAndPrice(products, orders, n, k);
+ OrderList customersWithSingleProduct = TaskUtils.FindCustomerWithSingleProduct(orders);
+ customersWithSingleProduct.Sort();
+
+ ShowProducts(Table1, products);
+ ShowOrders(Table2, orders);
+ ShowMostPopularProducts(Table5, orders, mostPopularProducts);
+ ShowOrdersWithPrices(Table3, customersWithSingleProduct, products);
+ ShowProducts(Table4, filteredProducts);
+
+ using (StreamWriter writer = new StreamWriter(Server.MapPath(outputFilename)))
+ {
+ InOutUtils.PrintProducts(writer, products, "Įtaisai");
+ InOutUtils.PrintOrders(writer, orders, "Pirkėjai");
+ InOutUtils.PrintMostPopularProducts(writer, orders, mostPopularProducts, "Populiariausi įtaisai");
+ InOutUtils.PrintOrdersWithPrices(writer, customersWithSingleProduct, products, "Vienos rūšies pirkėjai");
+ InOutUtils.PrintProducts(writer, filteredProducts, $"Atrinkti įtaisai (n={n}, k={k:f2})");
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/L3/LD_24/Forma1.aspx.designer.cs b/L3/LD_24/Forma1.aspx.designer.cs
new file mode 100644
index 0000000..691f56f
--- /dev/null
+++ b/L3/LD_24/Forma1.aspx.designer.cs
@@ -0,0 +1,195 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace LD_24 {
+
+
+ public partial class Forma1 {
+
+ ///
+ /// form1 control.
+ ///
+ ///
+ /// Auto-generated field.
+ /// To modify move field declaration from designer file to code-behind file.
+ ///
+ protected global::System.Web.UI.HtmlControls.HtmlForm form1;
+
+ ///
+ /// ValidationSummary1 control.
+ ///
+ ///
+ /// Auto-generated field.
+ /// To modify move field declaration from designer file to code-behind file.
+ ///
+ protected global::System.Web.UI.WebControls.ValidationSummary ValidationSummary1;
+
+ ///
+ /// Label5 control.
+ ///
+ ///
+ /// Auto-generated field.
+ /// To modify move field declaration from designer file to code-behind file.
+ ///
+ protected global::System.Web.UI.WebControls.Label Label5;
+
+ ///
+ /// TextBox1 control.
+ ///
+ ///
+ /// Auto-generated field.
+ /// To modify move field declaration from designer file to code-behind file.
+ ///
+ protected global::System.Web.UI.WebControls.TextBox TextBox1;
+
+ ///
+ /// RegularExpressionValidator1 control.
+ ///
+ ///
+ /// Auto-generated field.
+ /// To modify move field declaration from designer file to code-behind file.
+ ///
+ protected global::System.Web.UI.WebControls.RegularExpressionValidator RegularExpressionValidator1;
+
+ ///
+ /// Label6 control.
+ ///
+ ///
+ /// Auto-generated field.
+ /// To modify move field declaration from designer file to code-behind file.
+ ///
+ protected global::System.Web.UI.WebControls.Label Label6;
+
+ ///
+ /// TextBox2 control.
+ ///
+ ///
+ /// Auto-generated field.
+ /// To modify move field declaration from designer file to code-behind file.
+ ///
+ protected global::System.Web.UI.WebControls.TextBox TextBox2;
+
+ ///
+ /// RegularExpressionValidator2 control.
+ ///
+ ///
+ /// Auto-generated field.
+ /// To modify move field declaration from designer file to code-behind file.
+ ///
+ protected global::System.Web.UI.WebControls.RegularExpressionValidator RegularExpressionValidator2;
+
+ ///
+ /// Button1 control.
+ ///
+ ///
+ /// Auto-generated field.
+ /// To modify move field declaration from designer file to code-behind file.
+ ///
+ protected global::System.Web.UI.WebControls.Button Button1;
+
+ ///
+ /// ResultsDiv control.
+ ///
+ ///
+ /// Auto-generated field.
+ /// To modify move field declaration from designer file to code-behind file.
+ ///
+ protected global::System.Web.UI.HtmlControls.HtmlGenericControl ResultsDiv;
+
+ ///
+ /// Label1 control.
+ ///
+ ///
+ /// Auto-generated field.
+ /// To modify move field declaration from designer file to code-behind file.
+ ///
+ protected global::System.Web.UI.WebControls.Label Label1;
+
+ ///
+ /// Table1 control.
+ ///
+ ///
+ /// Auto-generated field.
+ /// To modify move field declaration from designer file to code-behind file.
+ ///
+ protected global::System.Web.UI.WebControls.Table Table1;
+
+ ///
+ /// Label2 control.
+ ///
+ ///
+ /// Auto-generated field.
+ /// To modify move field declaration from designer file to code-behind file.
+ ///
+ protected global::System.Web.UI.WebControls.Label Label2;
+
+ ///
+ /// Table2 control.
+ ///
+ ///
+ /// Auto-generated field.
+ /// To modify move field declaration from designer file to code-behind file.
+ ///
+ protected global::System.Web.UI.WebControls.Table Table2;
+
+ ///
+ /// Label8 control.
+ ///
+ ///
+ /// Auto-generated field.
+ /// To modify move field declaration from designer file to code-behind file.
+ ///
+ protected global::System.Web.UI.WebControls.Label Label8;
+
+ ///
+ /// Table5 control.
+ ///
+ ///
+ /// Auto-generated field.
+ /// To modify move field declaration from designer file to code-behind file.
+ ///
+ protected global::System.Web.UI.WebControls.Table Table5;
+
+ ///
+ /// Label4 control.
+ ///
+ ///
+ /// Auto-generated field.
+ /// To modify move field declaration from designer file to code-behind file.
+ ///
+ protected global::System.Web.UI.WebControls.Label Label4;
+
+ ///
+ /// Table3 control.
+ ///
+ ///
+ /// Auto-generated field.
+ /// To modify move field declaration from designer file to code-behind file.
+ ///
+ protected global::System.Web.UI.WebControls.Table Table3;
+
+ ///
+ /// Label7 control.
+ ///
+ ///
+ /// Auto-generated field.
+ /// To modify move field declaration from designer file to code-behind file.
+ ///
+ protected global::System.Web.UI.WebControls.Label Label7;
+
+ ///
+ /// Table4 control.
+ ///
+ ///
+ /// Auto-generated field.
+ /// To modify move field declaration from designer file to code-behind file.
+ ///
+ protected global::System.Web.UI.WebControls.Table Table4;
+ }
+}
diff --git a/L3/LD_24/Forma1Utils.aspx.cs b/L3/LD_24/Forma1Utils.aspx.cs
new file mode 100644
index 0000000..f36f09e
--- /dev/null
+++ b/L3/LD_24/Forma1Utils.aspx.cs
@@ -0,0 +1,123 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+using System.Web.UI;
+using System.Web.UI.WebControls;
+using LD_24.Code;
+
+namespace LD_24
+{
+ public partial class Forma1 : System.Web.UI.Page
+ {
+ ///
+ /// Show a list in a table
+ ///
+ /// Target table
+ /// Target list
+ /// Columns names
+ ///
+ private IEnumerable> ShowTable(Table table, IEnumerable list, params string[] columns)
+ {
+ TableRow header = new TableRow();
+ foreach (string column in columns)
+ {
+ header.Cells.Add(new TableCell { Text = column });
+ }
+ table.Rows.Add(header);
+
+ int n = 0;
+ foreach (object item in list)
+ {
+ TableRow row = new TableRow();
+ yield return Tuple.Create(item, row);
+ table.Rows.Add(row);
+ n++;
+ }
+
+ if (n == 0)
+ {
+ TableRow row = new TableRow();
+ row.Cells.Add(new TableCell { Text = "Nėra", ColumnSpan = columns.Length });
+ table.Rows.Add(row);
+ }
+ }
+
+ ///
+ /// Show a list of products in a table
+ ///
+ /// Target table
+ /// Target products
+ public void ShowProducts(Table table, ProductList products)
+ {
+ foreach (var tuple in ShowTable(table, products, "ID", "Vardas", "Kaina, eur."))
+ {
+ Product product = (Product)tuple.Item1;
+ TableRow row = tuple.Item2;
+ row.Cells.Add(new TableCell { Text = product.ID });
+ row.Cells.Add(new TableCell { Text = product.Name });
+ row.Cells.Add(new TableCell { Text = product.Price.ToString() });
+ }
+ }
+
+ ///
+ /// Show a list of orders in a table
+ ///
+ /// Target table
+ /// Target orders
+ public void ShowOrders(Table table, OrderList orders)
+ {
+ foreach (var tuple in ShowTable(table, orders, "Pavardė", "Vardas", "Įtaisas", "Įtaisų kiekis, vnt."))
+ {
+ Order order = (Order)tuple.Item1;
+ TableRow row = tuple.Item2;
+ row.Cells.Add(new TableCell { Text = order.CustomerSurname });
+ row.Cells.Add(new TableCell { Text = order.CustomerName });
+ row.Cells.Add(new TableCell { Text = order.ProductID.ToString() });
+ row.Cells.Add(new TableCell { Text = order.ProductAmount.ToString() });
+ }
+ }
+
+ ///
+ /// Show the most popular products in a table
+ ///
+ /// Target table
+ /// Target orders
+ /// List of most popular products
+ public void ShowMostPopularProducts(Table table, OrderList orders, ProductList popularProducts)
+ {
+ foreach (var tuple in ShowTable(table, popularProducts, "ID", "Vardas", "Įtaisų kiekis, vnt.", "Įtaisų kaina, eur."))
+ {
+ Product product = (Product)tuple.Item1;
+ TableRow row = tuple.Item2;
+ int sales = TaskUtils.CountProductSales(orders, product.ID);
+ row.Cells.Add(new TableCell { Text = product.ID });
+ row.Cells.Add(new TableCell { Text = product.Name });
+ row.Cells.Add(new TableCell { Text = sales.ToString() });
+ row.Cells.Add(new TableCell { Text = String.Format("{0:f2}", sales * product.Price) });
+ }
+ }
+
+ ///
+ /// Show a list of orders with their prices in a table
+ ///
+ /// Target table
+ /// Target orders
+ /// List of products
+ public void ShowOrdersWithPrices(Table table, OrderList orders, ProductList products)
+ {
+ foreach (var tuple in ShowTable(table, orders, "Pavardė", "Vardas", "Įtaisų kiekis, vnt.", "Sumokėta, eur."))
+ {
+ Order order = (Order)tuple.Item1;
+ TableRow row = tuple.Item2;
+ Product product = TaskUtils.FindByID(products, order.ProductID);
+
+ row.Cells.Add(new TableCell { Text = order.CustomerSurname });
+ row.Cells.Add(new TableCell { Text = order.CustomerName });
+ row.Cells.Add(new TableCell { Text = order.ProductAmount.ToString() });
+ row.Cells.Add(new TableCell { Text = String.Format("{0:f2}", order.ProductAmount * product.Price, 2) });
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/L3/LD_24/LD_24.csproj b/L3/LD_24/LD_24.csproj
new file mode 100644
index 0000000..60273d9
--- /dev/null
+++ b/L3/LD_24/LD_24.csproj
@@ -0,0 +1,179 @@
+
+
+
+
+
+ Debug
+ AnyCPU
+
+
+ 2.0
+ {AE159626-A105-440C-B997-F377C5F8F280}
+ {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}
+ Library
+ Properties
+ LD_24
+ LD_24
+ v4.6.1
+ true
+
+
+
+
+
+
+
+
+
+
+ true
+ full
+ false
+ bin\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ true
+ pdbonly
+ true
+ bin\
+ TRACE
+ prompt
+ 4
+
+
+
+ ..\packages\FluentAssertions.6.5.1\lib\netstandard2.0\FluentAssertions.dll
+
+
+
+ ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.0\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll
+
+
+ ..\packages\System.Threading.Tasks.Extensions.4.5.0\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ..\packages\xunit.abstractions.2.0.3\lib\net35\xunit.abstractions.dll
+
+
+ ..\packages\xunit.assert.2.4.1\lib\netstandard1.1\xunit.assert.dll
+
+
+ ..\packages\xunit.extensibility.core.2.4.1\lib\net452\xunit.core.dll
+
+
+ ..\packages\xunit.extensibility.execution.2.4.1\lib\net452\xunit.execution.desktop.dll
+
+
+
+
+ ..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.0\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Forma1.aspx
+ ASPXCodeBehind
+
+
+ Forma1.aspx
+
+
+ ASPXCodeBehind
+
+
+
+
+
+
+ Web.config
+
+
+ Web.config
+
+
+
+
+
+
+ 10.0
+ $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
+
+
+
+
+
+
+
+
+ True
+ True
+ 50592
+ /
+ http://localhost:50592/
+ False
+ False
+
+
+ False
+
+
+
+
+
+
+ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/L3/LD_24/Properties/AssemblyInfo.cs b/L3/LD_24/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..bd45cfd
--- /dev/null
+++ b/L3/LD_24/Properties/AssemblyInfo.cs
@@ -0,0 +1,35 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("LD_24")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("LD_24")]
+[assembly: AssemblyCopyright("Copyright © 2022")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("ae159626-a105-440c-b997-f377c5f8f280")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Revision and Build Numbers
+// by using the '*' as shown below:
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/L3/LD_24/Styles/main.css b/L3/LD_24/Styles/main.css
new file mode 100644
index 0000000..d479be0
--- /dev/null
+++ b/L3/LD_24/Styles/main.css
@@ -0,0 +1,10 @@
+table, th, td {
+ border: 1px solid black;
+ border-collapse: collapse;
+}
+
+table {
+ margin-bottom: 1em;
+ background-color: #FFFFCC;
+}
+
diff --git a/L3/LD_24/Web.Debug.config b/L3/LD_24/Web.Debug.config
new file mode 100644
index 0000000..fae9cfe
--- /dev/null
+++ b/L3/LD_24/Web.Debug.config
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/L3/LD_24/Web.Release.config b/L3/LD_24/Web.Release.config
new file mode 100644
index 0000000..da6e960
--- /dev/null
+++ b/L3/LD_24/Web.Release.config
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/L3/LD_24/Web.config b/L3/LD_24/Web.config
new file mode 100644
index 0000000..6b31877
--- /dev/null
+++ b/L3/LD_24/Web.config
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/L3/LD_24/interface-scheme.png b/L3/LD_24/interface-scheme.png
new file mode 100644
index 0000000..0090d87
Binary files /dev/null and b/L3/LD_24/interface-scheme.png differ
diff --git a/L3/LD_24/packages.config b/L3/LD_24/packages.config
new file mode 100644
index 0000000..5432864
--- /dev/null
+++ b/L3/LD_24/packages.config
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/L3/LD_24/tests/1/inputs/U24a.txt b/L3/LD_24/tests/1/inputs/U24a.txt
new file mode 100644
index 0000000..084097c
--- /dev/null
+++ b/L3/LD_24/tests/1/inputs/U24a.txt
@@ -0,0 +1,4 @@
+0, Atsuktuvas, 0.99
+1, Varztas, 0.05
+2, Laidas, 2.00
+3, Plaktukas, 2.99
\ No newline at end of file
diff --git a/L3/LD_24/tests/1/inputs/U24b.txt b/L3/LD_24/tests/1/inputs/U24b.txt
new file mode 100644
index 0000000..22a3639
--- /dev/null
+++ b/L3/LD_24/tests/1/inputs/U24b.txt
@@ -0,0 +1,12 @@
+Petraitis, Petras, 0, 10
+Petraitis, Petras, 1, 10
+Jonaitis, Jonas, 1, 20
+Jonaitis, Jonas, 1, 20
+Jonaitis, Jonas, 1, 20
+Onaite, Ona, 2, 200
+Jonaitis, Brolis, 1, 100
+Jonaitis, Brolis, 0, 100
+Jonaitis, Jonas, 1, 20
+Jonaitis, Jonas, 1, 20
+Jonaitis, Jonas, 2, 20
+Onaite, Ona, 0, 20
\ No newline at end of file
diff --git a/L3/LD_24/tests/1/outputs/Rezultatai.txt b/L3/LD_24/tests/1/outputs/Rezultatai.txt
new file mode 100644
index 0000000..8b0f319
--- /dev/null
+++ b/L3/LD_24/tests/1/outputs/Rezultatai.txt
@@ -0,0 +1,55 @@
+----------------------------
+| Įtaisai |
+----------------------------
+| ID | Vardas | Kaina |
+----------------------------
+| 0 | Atsuktuvas | 0,99 |
+| 1 | Varztas | 0,05 |
+| 2 | Laidas | 2,00 |
+| 3 | Plaktukas | 2,99 |
+----------------------------
+
+--------------------------------------------------
+| Pirkėjai |
+--------------------------------------------------
+| Pavardė | Vardas | Įtaisas | Įtaiso kiekis |
+--------------------------------------------------
+| Petraitis | Petras | 0 | 10 |
+| Petraitis | Petras | 1 | 10 |
+| Jonaitis | Jonas | 1 | 20 |
+| Jonaitis | Jonas | 1 | 20 |
+| Jonaitis | Jonas | 1 | 20 |
+| Onaite | Ona | 2 | 200 |
+| Jonaitis | Brolis | 1 | 100 |
+| Jonaitis | Brolis | 0 | 100 |
+| Jonaitis | Jonas | 1 | 20 |
+| Jonaitis | Jonas | 1 | 20 |
+| Jonaitis | Jonas | 2 | 20 |
+| Onaite | Ona | 0 | 20 |
+--------------------------------------------------
+
+------------------------------------------------------------
+| Populiariausi įtaisai |
+------------------------------------------------------------
+| ID | Vardas | Įtaisų kiekis, vnt. | Įtaisų kaina, eur. |
+------------------------------------------------------------
+| 2 | Laidas | 220 | 440,00 |
+------------------------------------------------------------
+
+----------------------------------------------------------
+| Vienos rūšies pirkėjai |
+----------------------------------------------------------
+| Pavardė | Vardas | Įtaiso kiekis, vnt. | Kaina, eur. |
+----------------------------------------------------------
+| Nėra |
+----------------------------------------------------------
+
+----------------------------------
+| Atrinkti įtaisai (n=1, k=1,00) |
+----------------------------------
+| ID | Vardas | Kaina |
+----------------------------------
+| 0 | Atsuktuvas | 0,99 |
+| 1 | Varztas | 0,05 |
+----------------------------------
+
diff --git a/L3/LD_24/tests/1/outputs/web.png b/L3/LD_24/tests/1/outputs/web.png
new file mode 100644
index 0000000..05e8ae4
Binary files /dev/null and b/L3/LD_24/tests/1/outputs/web.png differ
diff --git a/L3/LD_24/tests/2/inputs/U24a.txt b/L3/LD_24/tests/2/inputs/U24a.txt
new file mode 100644
index 0000000..084097c
--- /dev/null
+++ b/L3/LD_24/tests/2/inputs/U24a.txt
@@ -0,0 +1,4 @@
+0, Atsuktuvas, 0.99
+1, Varztas, 0.05
+2, Laidas, 2.00
+3, Plaktukas, 2.99
\ No newline at end of file
diff --git a/L3/LD_24/tests/2/inputs/U24b.txt b/L3/LD_24/tests/2/inputs/U24b.txt
new file mode 100644
index 0000000..8defdf5
--- /dev/null
+++ b/L3/LD_24/tests/2/inputs/U24b.txt
@@ -0,0 +1,9 @@
+Petraitis, Petras, 0, 10
+Jonaitis, Jonas, 1, 20
+Jonaitis, Jonas, 1, 20
+Jonaitis, Jonas, 1, 20
+Onaite, Ona, 2, 200
+Jonaitis, Brolis, 1, 100
+Jonaitis, Jonas, 1, 20
+Jonaitis, Jonas, 1, 20
+Onaite, Ona, 0, 20
\ No newline at end of file
diff --git a/L3/LD_24/tests/2/outputs/Rezultatai.txt b/L3/LD_24/tests/2/outputs/Rezultatai.txt
new file mode 100644
index 0000000..274e36a
--- /dev/null
+++ b/L3/LD_24/tests/2/outputs/Rezultatai.txt
@@ -0,0 +1,54 @@
+----------------------------
+| Įtaisai |
+----------------------------
+| ID | Vardas | Kaina |
+----------------------------
+| 0 | Atsuktuvas | 0,99 |
+| 1 | Varztas | 0,05 |
+| 2 | Laidas | 2,00 |
+| 3 | Plaktukas | 2,99 |
+----------------------------
+
+--------------------------------------------------
+| Pirkėjai |
+--------------------------------------------------
+| Pavardė | Vardas | Įtaisas | Įtaiso kiekis |
+--------------------------------------------------
+| Petraitis | Petras | 0 | 10 |
+| Jonaitis | Jonas | 1 | 20 |
+| Jonaitis | Jonas | 1 | 20 |
+| Jonaitis | Jonas | 1 | 20 |
+| Onaite | Ona | 2 | 200 |
+| Jonaitis | Brolis | 1 | 100 |
+| Jonaitis | Jonas | 1 | 20 |
+| Jonaitis | Jonas | 1 | 20 |
+| Onaite | Ona | 0 | 20 |
+--------------------------------------------------
+
+-------------------------------------------------------------
+| Populiariausi įtaisai |
+-------------------------------------------------------------
+| ID | Vardas | Įtaisų kiekis, vnt. | Įtaisų kaina, eur. |
+-------------------------------------------------------------
+| 1 | Varztas | 200 | 10,00 |
+| 2 | Laidas | 200 | 400,00 |
+-------------------------------------------------------------
+
+------------------------------------------------------------
+| Vienos rūšies pirkėjai |
+------------------------------------------------------------
+| Pavardė | Vardas | Įtaiso kiekis, vnt. | Kaina, eur. |
+------------------------------------------------------------
+| Jonaitis | Brolis | 100 | 5,00 |
+| Jonaitis | Jonas | 100 | 5,00 |
+| Petraitis | Petras | 10 | 9,90 |
+------------------------------------------------------------
+
+--------------------------------------
+| Atrinkti įtaisai (n=1000, k=10,00) |
+--------------------------------------
+| ID | Vardas | Kaina |
+--------------------------------------
+| Nėra |
+--------------------------------------
+
diff --git a/L3/LD_24/tests/2/outputs/web.png b/L3/LD_24/tests/2/outputs/web.png
new file mode 100644
index 0000000..d2d6416
Binary files /dev/null and b/L3/LD_24/tests/2/outputs/web.png differ