feat: copy over L2.LD_24
to L3.LD_24
This commit is contained in:
parent
8b9d63db33
commit
720bb2957f
25
L3/L3.sln
Normal file
25
L3/L3.sln
Normal file
@ -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
|
55
L3/LD_24/App_Data/Rezultatai.txt
Normal file
55
L3/LD_24/App_Data/Rezultatai.txt
Normal file
@ -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 |
|
||||||
|
----------------------------------
|
||||||
|
|
4
L3/LD_24/App_Data/U24a.txt
Normal file
4
L3/LD_24/App_Data/U24a.txt
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
0, Atsuktuvas, 0.99
|
||||||
|
1, Varztas, 0.05
|
||||||
|
2, Laidas, 2.00
|
||||||
|
3, Plaktukas, 2.99
|
12
L3/LD_24/App_Data/U24b.txt
Normal file
12
L3/LD_24/App_Data/U24b.txt
Normal file
@ -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
|
244
L3/LD_24/Code/InOutUtils.cs
Normal file
244
L3/LD_24/Code/InOutUtils.cs
Normal file
@ -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
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Class used for reading and writing to files
|
||||||
|
/// </summary>
|
||||||
|
public static class InOutUtils
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Read lines from a file
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filename">Target filename</param>
|
||||||
|
/// <returns>IEnumerable of all the lines</returns>
|
||||||
|
private static IEnumerable<string> ReadLines(string filename)
|
||||||
|
{
|
||||||
|
using (StreamReader reader = File.OpenText(filename))
|
||||||
|
{
|
||||||
|
string line;
|
||||||
|
while ((line = reader.ReadLine()) != null)
|
||||||
|
{
|
||||||
|
yield return line;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Read products from a file
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filename">Target file</param>
|
||||||
|
/// <returns>A list of products</returns>
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Read orders from a file
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filename">Target file</param>
|
||||||
|
/// <returns>A list of orders</returns>
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Print a single table row to file
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="writer">Target file</param>
|
||||||
|
/// <param name="cells">Cell data</param>
|
||||||
|
/// <param name="widths">Cell widths</param>
|
||||||
|
private static void PrintTableRow(StreamWriter writer, List<string> cells, List<int> 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("|");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Print a table to a file
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="writer">Target file</param>
|
||||||
|
/// <param name="header">Header above table</param>
|
||||||
|
/// <param name="list">Target list</param>
|
||||||
|
/// <param name="columns">Column names</param>
|
||||||
|
/// <returns>A IEnumerable for inserting values for each row</returns>
|
||||||
|
private static IEnumerable<Tuple<object, List<String>>> PrintTable(StreamWriter writer, string header, IEnumerable list, params string[] columns)
|
||||||
|
{
|
||||||
|
// 0. Collect all the rows
|
||||||
|
List<List<string>> rows = new List<List<string>>();
|
||||||
|
foreach (object item in list)
|
||||||
|
{
|
||||||
|
List<string> row = new List<string>();
|
||||||
|
yield return Tuple.Create(item, row);
|
||||||
|
rows.Add(row);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 1. Determine the width of each column
|
||||||
|
List<int> widths = new List<int>();
|
||||||
|
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<string>(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();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Print orders table to file
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="writer">Target file</param>
|
||||||
|
/// <param name="orders">List of orders</param>
|
||||||
|
/// <param name="header">Header above table</param>
|
||||||
|
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<string> row = tuple.Item2;
|
||||||
|
row.Add(order.CustomerSurname);
|
||||||
|
row.Add(order.CustomerName);
|
||||||
|
row.Add(order.ProductID);
|
||||||
|
row.Add(order.ProductAmount.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Print orders with prices table to file
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="writer">Target file</param>
|
||||||
|
/// <param name="orders">List of orders</param>
|
||||||
|
/// <param name="products">List of products</param>
|
||||||
|
/// <param name="header">Header above table</param>
|
||||||
|
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<string> 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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Print a products table to file
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="writer">Target file</param>
|
||||||
|
/// <param name="products">List of products</param>
|
||||||
|
/// <param name="header">Header above table</param>
|
||||||
|
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<string> row = tuple.Item2;
|
||||||
|
row.Add(product.ID);
|
||||||
|
row.Add(product.Name);
|
||||||
|
row.Add(String.Format("{0:f2}", product.Price));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Print a table of most popular products to file
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="writer">Target file</param>
|
||||||
|
/// <param name="orders">List of orders</param>
|
||||||
|
/// <param name="popularProducts">List of most popular products</param>
|
||||||
|
/// <param name="header">Header above table</param>
|
||||||
|
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<string> 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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
77
L3/LD_24/Code/Order.cs
Normal file
77
L3/LD_24/Code/Order.cs
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Web;
|
||||||
|
|
||||||
|
namespace LD_24.Code
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Class used for storing a single order
|
||||||
|
/// </summary>
|
||||||
|
public class Order
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Surname of customer who ordered
|
||||||
|
/// </summary>
|
||||||
|
public string CustomerSurname { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Name of customer who ordered
|
||||||
|
/// </summary>
|
||||||
|
public string CustomerName { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// ID of ordered product
|
||||||
|
/// </summary>
|
||||||
|
public string ProductID { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Amount of ordered products
|
||||||
|
/// </summary>
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
125
L3/LD_24/Code/OrderList.cs
Normal file
125
L3/LD_24/Code/OrderList.cs
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Web;
|
||||||
|
|
||||||
|
namespace LD_24.Code
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Stores a orders in a linked list
|
||||||
|
/// </summary>
|
||||||
|
public class OrderList : IEnumerable<Order>
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Append a value to the end of the linked list
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="customer"></param>
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Insert a value to the start of the linked list
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="customer"></param>
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get the number of values stored in linked list
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>A count</returns>
|
||||||
|
public int Count()
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
OrderNode current = head;
|
||||||
|
while (current != null)
|
||||||
|
{
|
||||||
|
current = current.Next;
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sorts the linked list
|
||||||
|
/// </summary>
|
||||||
|
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<Order> GetEnumerator()
|
||||||
|
{
|
||||||
|
OrderNode current = head;
|
||||||
|
while (current != null)
|
||||||
|
{
|
||||||
|
yield return current.Data;
|
||||||
|
current = current.Next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
IEnumerator IEnumerable.GetEnumerator()
|
||||||
|
{
|
||||||
|
return GetEnumerator();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
38
L3/LD_24/Code/Product.cs
Normal file
38
L3/LD_24/Code/Product.cs
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Web;
|
||||||
|
|
||||||
|
namespace LD_24.Code
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Holds informations about a single product
|
||||||
|
/// </summary>
|
||||||
|
public class Product
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Identification number of product
|
||||||
|
/// </summary>
|
||||||
|
public string ID { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Name of product
|
||||||
|
/// </summary>
|
||||||
|
public string Name { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Price of product
|
||||||
|
/// </summary>
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
103
L3/LD_24/Code/ProductList.cs
Normal file
103
L3/LD_24/Code/ProductList.cs
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Web;
|
||||||
|
|
||||||
|
namespace LD_24.Code
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Stores multiple products in a linked list
|
||||||
|
/// </summary>
|
||||||
|
public class ProductList : IEnumerable<Product>
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Append a value to the end of the linked list
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="product"></param>
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Inserts a value to the start of the linked list
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="product"></param>
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get the number of values stored in the linked list
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>A count</returns>
|
||||||
|
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<Product> GetEnumerator()
|
||||||
|
{
|
||||||
|
ProductNode current = head;
|
||||||
|
while (current != null)
|
||||||
|
{
|
||||||
|
yield return current.Data;
|
||||||
|
current = current.Next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
IEnumerator IEnumerable.GetEnumerator()
|
||||||
|
{
|
||||||
|
return GetEnumerator();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
187
L3/LD_24/Code/TaskUtils.cs
Normal file
187
L3/LD_24/Code/TaskUtils.cs
Normal file
@ -0,0 +1,187 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Web;
|
||||||
|
|
||||||
|
namespace LD_24.Code
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Various functions for operations on data
|
||||||
|
/// </summary>
|
||||||
|
public static class TaskUtils
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Finds the most popular products by the number of sales
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="orders">List of orders</param>
|
||||||
|
/// <returns>List of products ids</returns>
|
||||||
|
public static List<string> FindMostPopularProducts(OrderList orders)
|
||||||
|
{
|
||||||
|
Dictionary<string, int> productSales = new Dictionary<string, int>();
|
||||||
|
foreach (Order order in orders)
|
||||||
|
{
|
||||||
|
if (!productSales.ContainsKey(order.ProductID))
|
||||||
|
{
|
||||||
|
productSales.Add(order.ProductID, order.ProductAmount);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
productSales[order.ProductID] += order.ProductAmount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List<string> mostPopularProducts = new List<string>();
|
||||||
|
int mostPopularCount = 0;
|
||||||
|
foreach (string product in productSales.Keys)
|
||||||
|
{
|
||||||
|
int count = productSales[product];
|
||||||
|
if (count > mostPopularCount)
|
||||||
|
{
|
||||||
|
mostPopularCount = count;
|
||||||
|
mostPopularProducts = new List<string> { product };
|
||||||
|
} else if (count == mostPopularCount)
|
||||||
|
{
|
||||||
|
mostPopularProducts.Add(product);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return mostPopularProducts;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Counts the number of sales of a certain product
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="orders">List of products</param>
|
||||||
|
/// <param name="product">Target product id</param>
|
||||||
|
/// <returns>Sales</returns>
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Merge orders which have the same customer name, surname and product id into a single order.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="orders">A list of orders</param>
|
||||||
|
/// <returns>A list of orders where same orders have been merged</returns>
|
||||||
|
public static OrderList MergeOrders(OrderList orders)
|
||||||
|
{
|
||||||
|
Dictionary<Tuple<string, string, string>, Order> ordersByName = new Dictionary<Tuple<string, string, string>, 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Finds a product by it's id
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="products">List of products</param>
|
||||||
|
/// <param name="id">Target product id</param>
|
||||||
|
/// <returns>The product</returns>
|
||||||
|
public static Product FindByID(ProductList products, string id)
|
||||||
|
{
|
||||||
|
foreach (Product product in products)
|
||||||
|
{
|
||||||
|
if (product.ID == id)
|
||||||
|
{
|
||||||
|
return product;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Find all products by their ids
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="products">List of products</param>
|
||||||
|
/// <param name="ids">List of product ids</param>
|
||||||
|
/// <returns>List of products</returns>
|
||||||
|
public static ProductList FindByID(ProductList products, List<string> ids)
|
||||||
|
{
|
||||||
|
ProductList foundProducts = new ProductList();
|
||||||
|
foreach (string id in ids)
|
||||||
|
{
|
||||||
|
foundProducts.AddToEnd(FindByID(products, id));
|
||||||
|
}
|
||||||
|
return foundProducts;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Filter a list of products by sales and price.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="products">List of products</param>
|
||||||
|
/// <param name="orders">List of orders</param>
|
||||||
|
/// <param name="minSold">Minimmum sales amount</param>
|
||||||
|
/// <param name="maxPrice">Max product price</param>
|
||||||
|
/// <returns>A list of filtered products</returns>
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Find all customer which bought only 1 type of product
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="orders">List of orders</param>
|
||||||
|
/// <returns>A list of filtered orders</returns>
|
||||||
|
public static OrderList FindCustomerWithSingleProduct(OrderList orders)
|
||||||
|
{
|
||||||
|
Dictionary<Tuple<string, string>, OrderList> ordersByCusomer = new Dictionary<Tuple<string, string>, 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
47
L3/LD_24/Forma1.aspx
Normal file
47
L3/LD_24/Forma1.aspx
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Forma1.aspx.cs" Inherits="LD_24.Forma1" %>
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
|
<head runat="server">
|
||||||
|
<link href="~/Styles/main.css" rel="stylesheet" type="text/css" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<form id="form1" runat="server">
|
||||||
|
|
||||||
|
<asp:ValidationSummary ID="ValidationSummary1" runat="server" ForeColor="Red" />
|
||||||
|
<asp:Label ID="Label5" runat="server" Text="n:"></asp:Label>
|
||||||
|
<br />
|
||||||
|
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
|
||||||
|
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="TextBox1" ErrorMessage="Tiktais teigiami sveiki skaičiai yra galimi" ForeColor="Red" ValidationExpression="\d+"></asp:RegularExpressionValidator>
|
||||||
|
<br />
|
||||||
|
<asp:Label ID="Label6" runat="server" Text="k:"></asp:Label>
|
||||||
|
<br />
|
||||||
|
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
|
||||||
|
<asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ControlToValidate="TextBox2" ErrorMessage="Tiktais teigiami skaičiai yra galimi" ForeColor="Red" ValidationExpression="\d+(\.\d+)?"></asp:RegularExpressionValidator>
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
<asp:Button ID="Button1" runat="server" Text="Atrinkti" OnClick="Button1_Click" />
|
||||||
|
<div id="ResultsDiv" runat="server">
|
||||||
|
<br />
|
||||||
|
<hr />
|
||||||
|
<br />
|
||||||
|
<asp:Label ID="Label1" runat="server" Text="Įtaisai:"></asp:Label>
|
||||||
|
<asp:Table ID="Table1" runat="server">
|
||||||
|
</asp:Table>
|
||||||
|
<asp:Label ID="Label2" runat="server" Text="Pirkėjai:"></asp:Label>
|
||||||
|
<asp:Table ID="Table2" runat="server">
|
||||||
|
</asp:Table>
|
||||||
|
<asp:Label ID="Label8" runat="server" Text="Populiariausi įtaisai:"></asp:Label>
|
||||||
|
<asp:Table ID="Table5" runat="server">
|
||||||
|
</asp:Table>
|
||||||
|
<asp:Label ID="Label4" runat="server" Text="Vienos rūšies pirkėjai:"></asp:Label>
|
||||||
|
<asp:Table ID="Table3" runat="server">
|
||||||
|
</asp:Table>
|
||||||
|
<asp:Label ID="Label7" runat="server" Text="Atrinkti įtaisai:"></asp:Label>
|
||||||
|
<asp:Table ID="Table4" runat="server">
|
||||||
|
</asp:Table>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</body>
|
||||||
|
</html>
|
58
L3/LD_24/Forma1.aspx.cs
Normal file
58
L3/LD_24/Forma1.aspx.cs
Normal file
@ -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
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Main form
|
||||||
|
/// </summary>
|
||||||
|
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<string> 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})");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
195
L3/LD_24/Forma1.aspx.designer.cs
generated
Normal file
195
L3/LD_24/Forma1.aspx.designer.cs
generated
Normal file
@ -0,0 +1,195 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// This code was generated by a tool.
|
||||||
|
//
|
||||||
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||||
|
// the code is regenerated.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace LD_24 {
|
||||||
|
|
||||||
|
|
||||||
|
public partial class Forma1 {
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// form1 control.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Auto-generated field.
|
||||||
|
/// To modify move field declaration from designer file to code-behind file.
|
||||||
|
/// </remarks>
|
||||||
|
protected global::System.Web.UI.HtmlControls.HtmlForm form1;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ValidationSummary1 control.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Auto-generated field.
|
||||||
|
/// To modify move field declaration from designer file to code-behind file.
|
||||||
|
/// </remarks>
|
||||||
|
protected global::System.Web.UI.WebControls.ValidationSummary ValidationSummary1;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Label5 control.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Auto-generated field.
|
||||||
|
/// To modify move field declaration from designer file to code-behind file.
|
||||||
|
/// </remarks>
|
||||||
|
protected global::System.Web.UI.WebControls.Label Label5;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// TextBox1 control.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Auto-generated field.
|
||||||
|
/// To modify move field declaration from designer file to code-behind file.
|
||||||
|
/// </remarks>
|
||||||
|
protected global::System.Web.UI.WebControls.TextBox TextBox1;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// RegularExpressionValidator1 control.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Auto-generated field.
|
||||||
|
/// To modify move field declaration from designer file to code-behind file.
|
||||||
|
/// </remarks>
|
||||||
|
protected global::System.Web.UI.WebControls.RegularExpressionValidator RegularExpressionValidator1;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Label6 control.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Auto-generated field.
|
||||||
|
/// To modify move field declaration from designer file to code-behind file.
|
||||||
|
/// </remarks>
|
||||||
|
protected global::System.Web.UI.WebControls.Label Label6;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// TextBox2 control.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Auto-generated field.
|
||||||
|
/// To modify move field declaration from designer file to code-behind file.
|
||||||
|
/// </remarks>
|
||||||
|
protected global::System.Web.UI.WebControls.TextBox TextBox2;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// RegularExpressionValidator2 control.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Auto-generated field.
|
||||||
|
/// To modify move field declaration from designer file to code-behind file.
|
||||||
|
/// </remarks>
|
||||||
|
protected global::System.Web.UI.WebControls.RegularExpressionValidator RegularExpressionValidator2;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Button1 control.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Auto-generated field.
|
||||||
|
/// To modify move field declaration from designer file to code-behind file.
|
||||||
|
/// </remarks>
|
||||||
|
protected global::System.Web.UI.WebControls.Button Button1;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ResultsDiv control.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Auto-generated field.
|
||||||
|
/// To modify move field declaration from designer file to code-behind file.
|
||||||
|
/// </remarks>
|
||||||
|
protected global::System.Web.UI.HtmlControls.HtmlGenericControl ResultsDiv;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Label1 control.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Auto-generated field.
|
||||||
|
/// To modify move field declaration from designer file to code-behind file.
|
||||||
|
/// </remarks>
|
||||||
|
protected global::System.Web.UI.WebControls.Label Label1;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Table1 control.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Auto-generated field.
|
||||||
|
/// To modify move field declaration from designer file to code-behind file.
|
||||||
|
/// </remarks>
|
||||||
|
protected global::System.Web.UI.WebControls.Table Table1;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Label2 control.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Auto-generated field.
|
||||||
|
/// To modify move field declaration from designer file to code-behind file.
|
||||||
|
/// </remarks>
|
||||||
|
protected global::System.Web.UI.WebControls.Label Label2;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Table2 control.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Auto-generated field.
|
||||||
|
/// To modify move field declaration from designer file to code-behind file.
|
||||||
|
/// </remarks>
|
||||||
|
protected global::System.Web.UI.WebControls.Table Table2;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Label8 control.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Auto-generated field.
|
||||||
|
/// To modify move field declaration from designer file to code-behind file.
|
||||||
|
/// </remarks>
|
||||||
|
protected global::System.Web.UI.WebControls.Label Label8;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Table5 control.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Auto-generated field.
|
||||||
|
/// To modify move field declaration from designer file to code-behind file.
|
||||||
|
/// </remarks>
|
||||||
|
protected global::System.Web.UI.WebControls.Table Table5;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Label4 control.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Auto-generated field.
|
||||||
|
/// To modify move field declaration from designer file to code-behind file.
|
||||||
|
/// </remarks>
|
||||||
|
protected global::System.Web.UI.WebControls.Label Label4;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Table3 control.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Auto-generated field.
|
||||||
|
/// To modify move field declaration from designer file to code-behind file.
|
||||||
|
/// </remarks>
|
||||||
|
protected global::System.Web.UI.WebControls.Table Table3;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Label7 control.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Auto-generated field.
|
||||||
|
/// To modify move field declaration from designer file to code-behind file.
|
||||||
|
/// </remarks>
|
||||||
|
protected global::System.Web.UI.WebControls.Label Label7;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Table4 control.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Auto-generated field.
|
||||||
|
/// To modify move field declaration from designer file to code-behind file.
|
||||||
|
/// </remarks>
|
||||||
|
protected global::System.Web.UI.WebControls.Table Table4;
|
||||||
|
}
|
||||||
|
}
|
123
L3/LD_24/Forma1Utils.aspx.cs
Normal file
123
L3/LD_24/Forma1Utils.aspx.cs
Normal file
@ -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
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Show a list in a table
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="table">Target table</param>
|
||||||
|
/// <param name="list">Target list</param>
|
||||||
|
/// <param name="columns">Columns names</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private IEnumerable<Tuple<object, TableRow>> 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Show a list of products in a table
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="table">Target table</param>
|
||||||
|
/// <param name="products">Target products</param>
|
||||||
|
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() });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Show a list of orders in a table
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="table">Target table</param>
|
||||||
|
/// <param name="orders">Target orders</param>
|
||||||
|
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() });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Show the most popular products in a table
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="table">Target table</param>
|
||||||
|
/// <param name="orders">Target orders</param>
|
||||||
|
/// <param name="popularProducts">List of most popular products</param>
|
||||||
|
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) });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Show a list of orders with their prices in a table
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="table">Target table</param>
|
||||||
|
/// <param name="orders">Target orders</param>
|
||||||
|
/// <param name="products">List of products</param>
|
||||||
|
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) });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
179
L3/LD_24/LD_24.csproj
Normal file
179
L3/LD_24/LD_24.csproj
Normal file
@ -0,0 +1,179 @@
|
|||||||
|
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="..\packages\xunit.core.2.4.1\build\xunit.core.props" Condition="Exists('..\packages\xunit.core.2.4.1\build\xunit.core.props')" />
|
||||||
|
<Import Project="..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.0\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props" Condition="Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.0\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" />
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProductVersion>
|
||||||
|
</ProductVersion>
|
||||||
|
<SchemaVersion>2.0</SchemaVersion>
|
||||||
|
<ProjectGuid>{AE159626-A105-440C-B997-F377C5F8F280}</ProjectGuid>
|
||||||
|
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>LD_24</RootNamespace>
|
||||||
|
<AssemblyName>LD_24</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||||
|
<UseIISExpress>true</UseIISExpress>
|
||||||
|
<Use64BitIISExpress />
|
||||||
|
<IISExpressSSLPort />
|
||||||
|
<IISExpressAnonymousAuthentication />
|
||||||
|
<IISExpressWindowsAuthentication />
|
||||||
|
<IISExpressUseClassicPipelineMode />
|
||||||
|
<UseGlobalApplicationHostFile />
|
||||||
|
<NuGetPackageImportStamp>
|
||||||
|
</NuGetPackageImportStamp>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="FluentAssertions, Version=6.5.1.0, Culture=neutral, PublicKeyToken=33f2691a05b67b6a, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\FluentAssertions.6.5.1\lib\netstandard2.0\FluentAssertions.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.5.0\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.0\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Web.DynamicData" />
|
||||||
|
<Reference Include="System.Web.Entity" />
|
||||||
|
<Reference Include="System.Web.ApplicationServices" />
|
||||||
|
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
<Reference Include="System.Web.Extensions" />
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
<Reference Include="System.Drawing" />
|
||||||
|
<Reference Include="System.Web" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
<Reference Include="System.Configuration" />
|
||||||
|
<Reference Include="System.Web.Services" />
|
||||||
|
<Reference Include="System.EnterpriseServices" />
|
||||||
|
<Reference Include="xunit.abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\xunit.abstractions.2.0.3\lib\net35\xunit.abstractions.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="xunit.assert, Version=2.4.1.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\xunit.assert.2.4.1\lib\netstandard1.1\xunit.assert.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="xunit.core, Version=2.4.1.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\xunit.extensibility.core.2.4.1\lib\net452\xunit.core.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="xunit.execution.desktop, Version=2.4.1.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\xunit.extensibility.execution.2.4.1\lib\net452\xunit.execution.desktop.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform">
|
||||||
|
<HintPath>..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.0\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="App_Data\Rezultatai.txt" />
|
||||||
|
<Content Include="App_Data\U24a.txt" />
|
||||||
|
<Content Include="App_Data\U24b.txt" />
|
||||||
|
<Content Include="Forma1.aspx" />
|
||||||
|
<Content Include="Styles\main.css" />
|
||||||
|
<Content Include="tests\1\inputs\U24a.txt" />
|
||||||
|
<Content Include="tests\1\inputs\U24b.txt" />
|
||||||
|
<Content Include="tests\1\outputs\Rezultatai.txt" />
|
||||||
|
<Content Include="tests\1\outputs\web.png" />
|
||||||
|
<Content Include="tests\2\inputs\U24a.txt" />
|
||||||
|
<Content Include="tests\2\inputs\U24b.txt" />
|
||||||
|
<Content Include="tests\2\outputs\Rezultatai.txt" />
|
||||||
|
<Content Include="tests\2\outputs\web.png" />
|
||||||
|
<Content Include="Web.config" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Code\InOutUtils.cs" />
|
||||||
|
<Compile Include="Code\Order.cs" />
|
||||||
|
<Compile Include="Code\OrderList.cs" />
|
||||||
|
<Compile Include="Code\Product.cs" />
|
||||||
|
<Compile Include="Code\ProductList.cs" />
|
||||||
|
<Compile Include="Code\TaskUtils.cs" />
|
||||||
|
<Compile Include="Forma1.aspx.cs">
|
||||||
|
<DependentUpon>Forma1.aspx</DependentUpon>
|
||||||
|
<SubType>ASPXCodeBehind</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Forma1.aspx.designer.cs">
|
||||||
|
<DependentUpon>Forma1.aspx</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Forma1Utils.aspx.cs">
|
||||||
|
<SubType>ASPXCodeBehind</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="packages.config" />
|
||||||
|
<None Include="Web.Debug.config">
|
||||||
|
<DependentUpon>Web.config</DependentUpon>
|
||||||
|
</None>
|
||||||
|
<None Include="Web.Release.config">
|
||||||
|
<DependentUpon>Web.config</DependentUpon>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Analyzer Include="..\packages\xunit.analyzers.0.10.0\analyzers\dotnet\cs\xunit.analyzers.dll" />
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
||||||
|
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
|
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||||
|
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
|
||||||
|
<ProjectExtensions>
|
||||||
|
<VisualStudio>
|
||||||
|
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
|
||||||
|
<WebProjectProperties>
|
||||||
|
<UseIIS>True</UseIIS>
|
||||||
|
<AutoAssignPort>True</AutoAssignPort>
|
||||||
|
<DevelopmentServerPort>50592</DevelopmentServerPort>
|
||||||
|
<DevelopmentServerVPath>/</DevelopmentServerVPath>
|
||||||
|
<IISUrl>http://localhost:50592/</IISUrl>
|
||||||
|
<NTLMAuthentication>False</NTLMAuthentication>
|
||||||
|
<UseCustomServer>False</UseCustomServer>
|
||||||
|
<CustomServerUrl>
|
||||||
|
</CustomServerUrl>
|
||||||
|
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
|
||||||
|
</WebProjectProperties>
|
||||||
|
</FlavorProperties>
|
||||||
|
</VisualStudio>
|
||||||
|
</ProjectExtensions>
|
||||||
|
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||||
|
<PropertyGroup>
|
||||||
|
<ErrorText>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}.</ErrorText>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Error Condition="!Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.0\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.0\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props'))" />
|
||||||
|
<Error Condition="!Exists('..\packages\xunit.core.2.4.1\build\xunit.core.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.core.2.4.1\build\xunit.core.props'))" />
|
||||||
|
<Error Condition="!Exists('..\packages\xunit.core.2.4.1\build\xunit.core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.core.2.4.1\build\xunit.core.targets'))" />
|
||||||
|
</Target>
|
||||||
|
<Import Project="..\packages\xunit.core.2.4.1\build\xunit.core.targets" Condition="Exists('..\packages\xunit.core.2.4.1\build\xunit.core.targets')" />
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
</Project>
|
35
L3/LD_24/Properties/AssemblyInfo.cs
Normal file
35
L3/LD_24/Properties/AssemblyInfo.cs
Normal file
@ -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")]
|
10
L3/LD_24/Styles/main.css
Normal file
10
L3/LD_24/Styles/main.css
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
table, th, td {
|
||||||
|
border: 1px solid black;
|
||||||
|
border-collapse: collapse;
|
||||||
|
}
|
||||||
|
|
||||||
|
table {
|
||||||
|
margin-bottom: 1em;
|
||||||
|
background-color: #FFFFCC;
|
||||||
|
}
|
||||||
|
|
30
L3/LD_24/Web.Debug.config
Normal file
30
L3/LD_24/Web.Debug.config
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<!-- For more information on using web.config transformation visit https://go.microsoft.com/fwlink/?LinkId=125889 -->
|
||||||
|
|
||||||
|
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
|
||||||
|
<!--
|
||||||
|
In the example below, the "SetAttributes" transform will change the value of
|
||||||
|
"connectionString" to use "ReleaseSQLServer" only when the "Match" locator
|
||||||
|
finds an attribute "name" that has a value of "MyDB".
|
||||||
|
|
||||||
|
<connectionStrings>
|
||||||
|
<add name="MyDB"
|
||||||
|
connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True"
|
||||||
|
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
|
||||||
|
</connectionStrings>
|
||||||
|
-->
|
||||||
|
<system.web>
|
||||||
|
<!--
|
||||||
|
In the example below, the "Replace" transform will replace the entire
|
||||||
|
<customErrors> section of your web.config file.
|
||||||
|
Note that because there is only one customErrors section under the
|
||||||
|
<system.web> node, there is no need to use the "xdt:Locator" attribute.
|
||||||
|
|
||||||
|
<customErrors defaultRedirect="GenericError.htm"
|
||||||
|
mode="RemoteOnly" xdt:Transform="Replace">
|
||||||
|
<error statusCode="500" redirect="InternalError.htm"/>
|
||||||
|
</customErrors>
|
||||||
|
-->
|
||||||
|
</system.web>
|
||||||
|
</configuration>
|
31
L3/LD_24/Web.Release.config
Normal file
31
L3/LD_24/Web.Release.config
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<!-- For more information on using web.config transformation visit https://go.microsoft.com/fwlink/?LinkId=125889 -->
|
||||||
|
|
||||||
|
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
|
||||||
|
<!--
|
||||||
|
In the example below, the "SetAttributes" transform will change the value of
|
||||||
|
"connectionString" to use "ReleaseSQLServer" only when the "Match" locator
|
||||||
|
finds an attribute "name" that has a value of "MyDB".
|
||||||
|
|
||||||
|
<connectionStrings>
|
||||||
|
<add name="MyDB"
|
||||||
|
connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True"
|
||||||
|
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
|
||||||
|
</connectionStrings>
|
||||||
|
-->
|
||||||
|
<system.web>
|
||||||
|
<compilation xdt:Transform="RemoveAttributes(debug)" />
|
||||||
|
<!--
|
||||||
|
In the example below, the "Replace" transform will replace the entire
|
||||||
|
<customErrors> section of your web.config file.
|
||||||
|
Note that because there is only one customErrors section under the
|
||||||
|
<system.web> node, there is no need to use the "xdt:Locator" attribute.
|
||||||
|
|
||||||
|
<customErrors defaultRedirect="GenericError.htm"
|
||||||
|
mode="RemoteOnly" xdt:Transform="Replace">
|
||||||
|
<error statusCode="500" redirect="InternalError.htm"/>
|
||||||
|
</customErrors>
|
||||||
|
-->
|
||||||
|
</system.web>
|
||||||
|
</configuration>
|
27
L3/LD_24/Web.config
Normal file
27
L3/LD_24/Web.config
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
For more information on how to configure your ASP.NET application, please visit
|
||||||
|
https://go.microsoft.com/fwlink/?LinkId=169433
|
||||||
|
-->
|
||||||
|
<configuration>
|
||||||
|
<appSettings>
|
||||||
|
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
|
||||||
|
</appSettings>
|
||||||
|
<system.web>
|
||||||
|
<compilation debug="true" targetFramework="4.6.1"/>
|
||||||
|
<httpRuntime targetFramework="4.6.1"/>
|
||||||
|
<globalization fileEncoding="utf-8" />
|
||||||
|
</system.web>
|
||||||
|
<system.codedom>
|
||||||
|
<compilers>
|
||||||
|
<compiler language="c#;cs;csharp" extension=".cs"
|
||||||
|
type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
|
||||||
|
warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701"/>
|
||||||
|
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb"
|
||||||
|
type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
|
||||||
|
warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+"/>
|
||||||
|
</compilers>
|
||||||
|
</system.codedom>
|
||||||
|
|
||||||
|
</configuration>
|
BIN
L3/LD_24/interface-scheme.png
Normal file
BIN
L3/LD_24/interface-scheme.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 39 KiB |
14
L3/LD_24/packages.config
Normal file
14
L3/LD_24/packages.config
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<packages>
|
||||||
|
<package id="FluentAssertions" version="6.5.1" targetFramework="net461" />
|
||||||
|
<package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="2.0.0" targetFramework="net461" />
|
||||||
|
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.0" targetFramework="net461" />
|
||||||
|
<package id="System.Threading.Tasks.Extensions" version="4.5.0" targetFramework="net461" />
|
||||||
|
<package id="xunit" version="2.4.1" targetFramework="net461" />
|
||||||
|
<package id="xunit.abstractions" version="2.0.3" targetFramework="net461" />
|
||||||
|
<package id="xunit.analyzers" version="0.10.0" targetFramework="net461" />
|
||||||
|
<package id="xunit.assert" version="2.4.1" targetFramework="net461" />
|
||||||
|
<package id="xunit.core" version="2.4.1" targetFramework="net461" />
|
||||||
|
<package id="xunit.extensibility.core" version="2.4.1" targetFramework="net461" />
|
||||||
|
<package id="xunit.extensibility.execution" version="2.4.1" targetFramework="net461" />
|
||||||
|
</packages>
|
4
L3/LD_24/tests/1/inputs/U24a.txt
Normal file
4
L3/LD_24/tests/1/inputs/U24a.txt
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
0, Atsuktuvas, 0.99
|
||||||
|
1, Varztas, 0.05
|
||||||
|
2, Laidas, 2.00
|
||||||
|
3, Plaktukas, 2.99
|
12
L3/LD_24/tests/1/inputs/U24b.txt
Normal file
12
L3/LD_24/tests/1/inputs/U24b.txt
Normal file
@ -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
|
55
L3/LD_24/tests/1/outputs/Rezultatai.txt
Normal file
55
L3/LD_24/tests/1/outputs/Rezultatai.txt
Normal file
@ -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 |
|
||||||
|
----------------------------------
|
||||||
|
|
BIN
L3/LD_24/tests/1/outputs/web.png
Normal file
BIN
L3/LD_24/tests/1/outputs/web.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 17 KiB |
4
L3/LD_24/tests/2/inputs/U24a.txt
Normal file
4
L3/LD_24/tests/2/inputs/U24a.txt
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
0, Atsuktuvas, 0.99
|
||||||
|
1, Varztas, 0.05
|
||||||
|
2, Laidas, 2.00
|
||||||
|
3, Plaktukas, 2.99
|
9
L3/LD_24/tests/2/inputs/U24b.txt
Normal file
9
L3/LD_24/tests/2/inputs/U24b.txt
Normal file
@ -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
|
54
L3/LD_24/tests/2/outputs/Rezultatai.txt
Normal file
54
L3/LD_24/tests/2/outputs/Rezultatai.txt
Normal file
@ -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 |
|
||||||
|
--------------------------------------
|
||||||
|
|
BIN
L3/LD_24/tests/2/outputs/web.png
Normal file
BIN
L3/LD_24/tests/2/outputs/web.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 17 KiB |
Loading…
Reference in New Issue
Block a user