diff --git a/L3/LD_24/App_Data/Rezultatai.txt b/L3/LD_24/App_Data/Rezultatai.txt
index 8b0f319..288d333 100644
--- a/L3/LD_24/App_Data/Rezultatai.txt
+++ b/L3/LD_24/App_Data/Rezultatai.txt
@@ -3,10 +3,10 @@
----------------------------
| ID | Vardas | Kaina |
----------------------------
-| 0 | Atsuktuvas | 0,99 |
-| 1 | Varztas | 0,05 |
-| 2 | Laidas | 2,00 |
-| 3 | Plaktukas | 2,99 |
+| 0 | Atsuktuvas | 0.99 |
+| 1 | Varztas | 0.05 |
+| 2 | Laidas | 2.00 |
+| 3 | Plaktukas | 2.99 |
----------------------------
--------------------------------------------------
@@ -33,7 +33,7 @@
------------------------------------------------------------
| ID | Vardas | Įtaisų kiekis, vnt. | Įtaisų kaina, eur. |
------------------------------------------------------------
-| 2 | Laidas | 220 | 440,00 |
+| 2 | Laidas | 220 | 440.00 |
------------------------------------------------------------
----------------------------------------------------------
@@ -45,11 +45,11 @@
----------------------------------------------------------
----------------------------------
-| Atrinkti įtaisai (n=1, k=1,00) |
+| Atrinkti įtaisai (n=1, k=1.00) |
----------------------------------
| ID | Vardas | Kaina |
----------------------------------
-| 0 | Atsuktuvas | 0,99 |
-| 1 | Varztas | 0,05 |
+| 0 | Atsuktuvas | 0.99 |
+| 1 | Varztas | 0.05 |
----------------------------------
diff --git a/L3/LD_24/Code/InOutUtils.cs b/L3/LD_24/Code/InOutUtils.cs
index adab74b..df1d0b3 100644
--- a/L3/LD_24/Code/InOutUtils.cs
+++ b/L3/LD_24/Code/InOutUtils.cs
@@ -35,16 +35,16 @@ namespace LD_24.Code
///
/// Target file
/// A list of products
- public static ProductList ReadProducts(string filename)
+ public static LinkedList ReadProducts(string filename)
{
- ProductList products = new ProductList();
+ LinkedList products = new LinkedList();
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));
+ products.Add(new Product(id, name, price));
}
return products;
}
@@ -54,9 +54,9 @@ namespace LD_24.Code
///
/// Target file
/// A list of orders
- public static OrderList ReadOrders(string filename)
+ public static LinkedList ReadOrders(string filename)
{
- OrderList orders = new OrderList();
+ LinkedList orders = new LinkedList();
foreach (string line in ReadLines(filename))
{
string[] parts = line.Split(',');
@@ -64,7 +64,7 @@ namespace LD_24.Code
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));
+ orders.Add(new Order(customerSurname, customerName, productID, productAmount));
}
return orders;
}
@@ -95,11 +95,11 @@ namespace LD_24.Code
/// 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)
+ 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)
+ foreach (T item in list)
{
List row = new List();
yield return Tuple.Create(item, row);
@@ -167,11 +167,11 @@ namespace LD_24.Code
/// Target file
/// List of orders
/// Header above table
- public static void PrintOrders(StreamWriter writer, OrderList orders, string header)
+ public static void PrintOrders(StreamWriter writer, IEnumerable orders, string header)
{
foreach (var tuple in PrintTable(writer, header, orders, "Pavardė", "Vardas", "-Įtaisas", "-Įtaiso kiekis"))
{
- Order order = (Order)tuple.Item1;
+ Order order = tuple.Item1;
List row = tuple.Item2;
row.Add(order.CustomerSurname);
row.Add(order.CustomerName);
@@ -187,18 +187,18 @@ namespace LD_24.Code
/// List of orders
/// List of products
/// Header above table
- public static void PrintOrdersWithPrices(StreamWriter writer, OrderList orders, ProductList products, string header)
+ public static void PrintOrdersWithPrices(StreamWriter writer, IEnumerable orders, IEnumerable products, string header)
{
foreach (var tuple in PrintTable(writer, header, orders, "Pavardė", "Vardas", "-Įtaiso kiekis, vnt.", "-Kaina, eur."))
{
- Order order = (Order)tuple.Item1;
+ 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));
+ row.Add(string.Format("{0:f2}", order.ProductAmount * product.Price));
}
}
@@ -208,15 +208,15 @@ namespace LD_24.Code
/// Target file
/// List of products
/// Header above table
- public static void PrintProducts(StreamWriter writer, ProductList products, string header)
+ public static void PrintProducts(StreamWriter writer, IEnumerable products, string header)
{
foreach (var tuple in PrintTable(writer, header, products, "ID", "Vardas", "-Kaina"))
{
- Product product = (Product)tuple.Item1;
+ Product product = tuple.Item1;
List row = tuple.Item2;
row.Add(product.ID);
row.Add(product.Name);
- row.Add(String.Format("{0:f2}", product.Price));
+ row.Add(string.Format("{0:f2}", product.Price));
}
}
@@ -227,17 +227,17 @@ namespace LD_24.Code
/// List of orders
/// List of most popular products
/// Header above table
- public static void PrintMostPopularProducts(StreamWriter writer, OrderList orders, ProductList popularProducts, string header)
+ public static void PrintMostPopularProducts(StreamWriter writer, IEnumerable orders, IEnumerable popularProducts, string header)
{
foreach (var tuple in PrintTable(writer, header, popularProducts, "ID", "Vardas", "-Įtaisų kiekis, vnt.", "-Įtaisų kaina, eur."))
{
- Product product = (Product)tuple.Item1;
+ 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));
+ row.Add(string.Format("{0:f2}", sales * product.Price));
}
}
}
diff --git a/L3/LD_24/Code/LinkedList.cs b/L3/LD_24/Code/LinkedList.cs
new file mode 100644
index 0000000..4a389d5
--- /dev/null
+++ b/L3/LD_24/Code/LinkedList.cs
@@ -0,0 +1,94 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+namespace LD_24.Code
+{
+ public class LinkedList : IEnumerable
+ where T: IComparable, IEquatable
+ {
+ class Node
+ {
+ public T Data { get; set; }
+ public Node Next { get; set; }
+
+ public Node(T data, Node next = null)
+ {
+ Data = data;
+ Next = next;
+ }
+ }
+
+ private Node head;
+ private Node tail;
+
+ public void Add(T customer)
+ {
+ Node node = new Node(customer);
+ if (tail != null && head != null)
+ {
+ tail.Next = node;
+ tail = node;
+ }
+ else
+ {
+ tail = node;
+ head = node;
+ }
+ }
+
+ public int Count()
+ {
+ int count = 0;
+ Node current = head;
+ while (current != null)
+ {
+ current = current.Next;
+ count++;
+ }
+ return count;
+ }
+
+ public bool IsEmpty()
+ {
+ return head == null;
+ }
+
+ public void Sort()
+ {
+ for (Node nodeA = head; nodeA != null; nodeA = nodeA.Next)
+ {
+ Node min = nodeA;
+ for (Node nodeB = nodeA.Next; nodeB != null; nodeB = nodeB.Next)
+ {
+ if (nodeB.Data.CompareTo(min.Data) > 0)
+ {
+ min = nodeB;
+ }
+ }
+
+ T tmp = nodeA.Data;
+ nodeA.Data = min.Data;
+ min.Data = tmp;
+ }
+ }
+
+ public override string ToString()
+ {
+ return String.Format("LinkedList<{0}>{ Count = '{0}' }", Count());
+ }
+
+ public IEnumerator GetEnumerator()
+ {
+ for (Node d = head; d != null; d = d.Next)
+ yield return d.Data;
+ }
+
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return GetEnumerator();
+ }
+ }
+}
\ No newline at end of file
diff --git a/L3/LD_24/Code/Order.cs b/L3/LD_24/Code/Order.cs
index 1931ccd..a99f300 100644
--- a/L3/LD_24/Code/Order.cs
+++ b/L3/LD_24/Code/Order.cs
@@ -8,7 +8,7 @@ namespace LD_24.Code
///
/// Class used for storing a single order
///
- public class Order
+ public class Order: IEquatable, IComparable
{
///
/// Surname of customer who ordered
@@ -40,38 +40,44 @@ namespace LD_24.Code
return String.Format("Order{Name = '{0}'}", CustomerName);
}
- public static bool operator <(Order a, Order b)
+ public int CompareTo(Order other)
{
- if (a.ProductAmount > b.ProductAmount)
+ if (ProductAmount > other.ProductAmount)
{
- return true;
+ return 1;
}
- else if (a.ProductAmount == b.ProductAmount)
+ else if (ProductAmount == other.ProductAmount)
{
- int surnameCompare = a.CustomerSurname.CompareTo(b.CustomerSurname);
+ int surnameCompare = CustomerSurname.CompareTo(other.CustomerSurname);
if (surnameCompare < 0)
{
- return true;
+ return 1;
}
- else if (surnameCompare == 0)
+ else if (surnameCompare == 0 && CustomerName.CompareTo(other.CustomerName) < 0)
{
- return a.CustomerName.CompareTo(b.CustomerName) < 0;
+ return 1;
}
}
- return false;
+ return Equals(other) ? 0 : -1;
}
- public static bool operator >(Order a, Order b)
+
+ public bool Equals(Order other)
{
- return !(a < b && a == b);
+ return CustomerSurname == other.CustomerSurname &&
+ CustomerName == other.CustomerName &&
+ ProductID == other.ProductID &&
+ ProductAmount == other.ProductAmount;
}
- public static bool operator ==(Order a, Order b)
+
+ public override int GetHashCode()
{
- return a.ProductAmount == b.ProductAmount && a.CustomerName == b.CustomerName && a.CustomerSurname == b.CustomerSurname;
- }
- public static bool operator !=(Order a, Order b)
- {
- return !(a == b);
+ int hashCode = -273364163;
+ hashCode = hashCode * -1521134295 + EqualityComparer.Default.GetHashCode(CustomerSurname);
+ hashCode = hashCode * -1521134295 + EqualityComparer.Default.GetHashCode(CustomerName);
+ hashCode = hashCode * -1521134295 + EqualityComparer.Default.GetHashCode(ProductID);
+ hashCode = hashCode * -1521134295 + ProductAmount.GetHashCode();
+ return hashCode;
}
}
}
\ No newline at end of file
diff --git a/L3/LD_24/Code/OrderList.cs b/L3/LD_24/Code/OrderList.cs
deleted file mode 100644
index 9e04ab2..0000000
--- a/L3/LD_24/Code/OrderList.cs
+++ /dev/null
@@ -1,125 +0,0 @@
-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
index d2ad1bc..de7a900 100644
--- a/L3/LD_24/Code/Product.cs
+++ b/L3/LD_24/Code/Product.cs
@@ -8,7 +8,7 @@ namespace LD_24.Code
///
/// Holds informations about a single product
///
- public class Product
+ public class Product: IEquatable, IComparable
{
///
/// Identification number of product
@@ -34,5 +34,26 @@ namespace LD_24.Code
{
return String.Format("Product{ID = '{0}'}", ID);
}
+
+ public bool Equals(Product other)
+ {
+ return ID == other.ID &&
+ Name == other.Name &&
+ Price == other.Price;
+ }
+
+ public override int GetHashCode()
+ {
+ int hashCode = 560300832;
+ hashCode = hashCode * -1521134295 + EqualityComparer.Default.GetHashCode(ID);
+ hashCode = hashCode * -1521134295 + EqualityComparer.Default.GetHashCode(Name);
+ hashCode = hashCode * -1521134295 + Price.GetHashCode();
+ return hashCode;
+ }
+
+ public int CompareTo(Product other)
+ {
+ return ID.CompareTo(other.ID);
+ }
}
}
diff --git a/L3/LD_24/Code/ProductList.cs b/L3/LD_24/Code/ProductList.cs
deleted file mode 100644
index db56384..0000000
--- a/L3/LD_24/Code/ProductList.cs
+++ /dev/null
@@ -1,103 +0,0 @@
-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
index 41262fe..cd7c7e9 100644
--- a/L3/LD_24/Code/TaskUtils.cs
+++ b/L3/LD_24/Code/TaskUtils.cs
@@ -16,7 +16,7 @@ namespace LD_24.Code
///
/// List of orders
/// List of products ids
- public static List FindMostPopularProducts(OrderList orders)
+ public static List FindMostPopularProducts(IEnumerable orders)
{
Dictionary productSales = new Dictionary();
foreach (Order order in orders)
@@ -55,7 +55,7 @@ namespace LD_24.Code
/// List of products
/// Target product id
/// Sales
- public static int CountProductSales(OrderList orders, string product)
+ public static int CountProductSales(IEnumerable orders, string product)
{
int sales = 0;
foreach (Order order in orders)
@@ -73,7 +73,7 @@ namespace LD_24.Code
///
/// A list of orders
/// A list of orders where same orders have been merged
- public static OrderList MergeOrders(OrderList orders)
+ public static LinkedList MergeOrders(IEnumerable orders)
{
Dictionary, Order> ordersByName = new Dictionary, Order>();
foreach (var order in orders)
@@ -88,10 +88,10 @@ namespace LD_24.Code
}
}
- OrderList mergedOrders = new OrderList();
+ LinkedList mergedOrders = new LinkedList();
foreach (var order in ordersByName.Values)
{
- mergedOrders.AddToEnd(order);
+ mergedOrders.Add(order);
}
return mergedOrders;
}
@@ -102,7 +102,7 @@ namespace LD_24.Code
/// List of products
/// Target product id
/// The product
- public static Product FindByID(ProductList products, string id)
+ public static Product FindByID(IEnumerable products, string id)
{
foreach (Product product in products)
{
@@ -120,12 +120,12 @@ namespace LD_24.Code
/// List of products
/// List of product ids
/// List of products
- public static ProductList FindByID(ProductList products, List ids)
+ public static LinkedList FindByID(IEnumerable products, List ids)
{
- ProductList foundProducts = new ProductList();
+ LinkedList foundProducts = new LinkedList();
foreach (string id in ids)
{
- foundProducts.AddToEnd(FindByID(products, id));
+ foundProducts.Add(FindByID(products, id));
}
return foundProducts;
}
@@ -138,9 +138,9 @@ namespace LD_24.Code
/// Minimmum sales amount
/// Max product price
/// A list of filtered products
- public static ProductList FilterByQuantitySoldAndPrice(ProductList products, OrderList orders, int minSold, decimal maxPrice)
+ public static LinkedList FilterByQuantitySoldAndPrice(IEnumerable products, IEnumerable orders, int minSold, decimal maxPrice)
{
- ProductList filtered = new ProductList();
+ LinkedList filtered = new LinkedList();
foreach (Product product in products)
{
if (product.Price < maxPrice)
@@ -148,7 +148,7 @@ namespace LD_24.Code
int sold = CountProductSales(orders, product.ID);
if (sold >= minSold)
{
- filtered.AddToEnd(product);
+ filtered.Add(product);
}
}
}
@@ -160,25 +160,25 @@ namespace LD_24.Code
///
/// List of orders
/// A list of filtered orders
- public static OrderList FindCustomerWithSingleProduct(OrderList orders)
+ public static LinkedList FindCustomerWithSingleProduct(IEnumerable orders)
{
- Dictionary, OrderList> ordersByCusomer = new Dictionary, OrderList>();
- foreach (var order in TaskUtils.MergeOrders(orders))
+ var ordersByCusomer = new Dictionary, LinkedList>();
+ foreach (var order in MergeOrders(orders))
{
var key = Tuple.Create(order.CustomerName, order.CustomerSurname);
if (!ordersByCusomer.ContainsKey(key))
{
- ordersByCusomer.Add(key, new OrderList());
+ ordersByCusomer.Add(key, new LinkedList());
}
- ordersByCusomer[key].AddToEnd(order);
+ ordersByCusomer[key].Add(order);
}
- OrderList finalList = new OrderList();
+ LinkedList finalList = new LinkedList();
foreach (var customerOrders in ordersByCusomer.Values)
{
if (customerOrders.Count() == 1)
{
- finalList.AddToEnd(customerOrders.First());
+ finalList.Add(customerOrders.First());
}
}
return finalList;
diff --git a/L3/LD_24/Forma1.aspx.cs b/L3/LD_24/Forma1.aspx.cs
index f9ee37a..cdb7ab7 100644
--- a/L3/LD_24/Forma1.aspx.cs
+++ b/L3/LD_24/Forma1.aspx.cs
@@ -30,13 +30,13 @@ namespace LD_24
FindControl("ResultsDiv").Visible = true;
- ProductList products = InOutUtils.ReadProducts(Server.MapPath(inputFileA));
- OrderList orders = InOutUtils.ReadOrders(Server.MapPath(inputFileB));
+ var products = InOutUtils.ReadProducts(Server.MapPath(inputFileA));
+ var 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);
+ var mostPopularProducts = TaskUtils.FindByID(products, mostPopularProductIds);
+ var filteredProducts = TaskUtils.FilterByQuantitySoldAndPrice(products, orders, n, k);
+ var customersWithSingleProduct = TaskUtils.FindCustomerWithSingleProduct(orders);
customersWithSingleProduct.Sort();
ShowProducts(Table1, products);
diff --git a/L3/LD_24/Forma1Utils.aspx.cs b/L3/LD_24/Forma1Utils.aspx.cs
index f36f09e..c91d3cf 100644
--- a/L3/LD_24/Forma1Utils.aspx.cs
+++ b/L3/LD_24/Forma1Utils.aspx.cs
@@ -18,7 +18,7 @@ namespace LD_24
/// Target list
/// Columns names
///
- private IEnumerable> ShowTable(Table table, IEnumerable list, params string[] columns)
+ private IEnumerable> ShowTable(Table table, IEnumerable list, params string[] columns)
{
TableRow header = new TableRow();
foreach (string column in columns)
@@ -28,7 +28,7 @@ namespace LD_24
table.Rows.Add(header);
int n = 0;
- foreach (object item in list)
+ foreach (T item in list)
{
TableRow row = new TableRow();
yield return Tuple.Create(item, row);
@@ -49,11 +49,11 @@ namespace LD_24
///
/// Target table
/// Target products
- public void ShowProducts(Table table, ProductList products)
+ public void ShowProducts(Table table, IEnumerable products)
{
foreach (var tuple in ShowTable(table, products, "ID", "Vardas", "Kaina, eur."))
{
- Product product = (Product)tuple.Item1;
+ Product product = tuple.Item1;
TableRow row = tuple.Item2;
row.Cells.Add(new TableCell { Text = product.ID });
row.Cells.Add(new TableCell { Text = product.Name });
@@ -66,11 +66,11 @@ namespace LD_24
///
/// Target table
/// Target orders
- public void ShowOrders(Table table, OrderList orders)
+ public void ShowOrders(Table table, IEnumerable orders)
{
foreach (var tuple in ShowTable(table, orders, "Pavardė", "Vardas", "Įtaisas", "Įtaisų kiekis, vnt."))
{
- Order order = (Order)tuple.Item1;
+ Order order = tuple.Item1;
TableRow row = tuple.Item2;
row.Cells.Add(new TableCell { Text = order.CustomerSurname });
row.Cells.Add(new TableCell { Text = order.CustomerName });
@@ -85,17 +85,17 @@ namespace LD_24
/// Target table
/// Target orders
/// List of most popular products
- public void ShowMostPopularProducts(Table table, OrderList orders, ProductList popularProducts)
+ public void ShowMostPopularProducts(Table table, IEnumerable orders, IEnumerable popularProducts)
{
foreach (var tuple in ShowTable(table, popularProducts, "ID", "Vardas", "Įtaisų kiekis, vnt.", "Įtaisų kaina, eur."))
{
- Product product = (Product)tuple.Item1;
+ 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) });
+ row.Cells.Add(new TableCell { Text = string.Format("{0:f2}", sales * product.Price) });
}
}
@@ -105,18 +105,18 @@ namespace LD_24
/// Target table
/// Target orders
/// List of products
- public void ShowOrdersWithPrices(Table table, OrderList orders, ProductList products)
+ public void ShowOrdersWithPrices(Table table, IEnumerable orders, IEnumerable products)
{
foreach (var tuple in ShowTable(table, orders, "Pavardė", "Vardas", "Įtaisų kiekis, vnt.", "Sumokėta, eur."))
{
- Order order = (Order)tuple.Item1;
+ 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) });
+ row.Cells.Add(new TableCell { Text = string.Format("{0:f2}", order.ProductAmount * product.Price, 2) });
}
}
}
diff --git a/L3/LD_24/LD_24.csproj b/L3/LD_24/LD_24.csproj
index 60273d9..20d63f1 100644
--- a/L3/LD_24/LD_24.csproj
+++ b/L3/LD_24/LD_24.csproj
@@ -106,10 +106,9 @@
+
-
-
Forma1.aspx