/// <summary> /// Creates the list containing data read from the text file. /// THE STUDENT SHOULD IMPLEMENT THIS METHOD ACCORDING THE TASK. /// </summary> /// <param name="fileName">The name of the text file</param> /// <returns>List with data from file</returns> public static LinkList <Operation> ReadFromFile(string fileName) { StreamReader reader = new StreamReader(fileName); LinkList <Operation> operations = new LinkList <Operation>(); string text = reader.ReadToEnd(); string[] lines = text.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); foreach (var line in lines) { string[] data = line.Split(new string[] { "; " }, StringSplitOptions.RemoveEmptyEntries); if (data.Length == 5) { Operation Operation = new Operation(int.Parse(data[0]), data[1], data[2], int.Parse(data[3]), decimal.Parse(data[4])); operations.Add(Operation); } } return(operations); }
/// <summary> /// THE STUDENT SHOULD IMPLEMENT THIS METHOD ACCORDING THE TASK. /// </summary> static void Main() { const string BalFile = "Balandis.txt"; const string KovFile = "Kovas.txt"; const string CRF = "Rezultatai.txt"; if (File.Exists(CRF)) { File.Delete(CRF); } LinkList <Operation> BalOperations = InOut.ReadFromFile(BalFile); LinkList <Operation> KovOperations = InOut.ReadFromFile(KovFile); InOut.PrintToFile(CRF, "Balandzio duom", BalOperations); InOut.PrintToFile(CRF, "Kovo duom", KovOperations); BalOperations.Sort(); KovOperations.Sort(); InOut.PrintToFile(CRF, "Rikiuoti Balandzio duom", BalOperations); InOut.PrintToFile(CRF, "Rikiuoti Kovo duom", KovOperations); }
/// <summary> /// Removes objects, those certain property value is less than or equal to /// <paramref name="value"/>, from the list. /// THE STUDENT SHOULD IMPLEMENT THIS METHOD ACCORDING THE TASK. /// THE STUDENT SHOULDN'T CHANGE THE SIGNATURE OF THE METHOD! /// </summary> /// <typeparam name="TData">The type of the data objects stored in the list</typeparam> /// <typeparam name="TCriterion">The type of the criterion</typeparam> /// <param name="source">The list to be modified</param> /// <param name="value">The upper bound of the property value for objects to be removed /// form the list. </param> public static void Remove <TData, TCriterion>(LinkList <TData> source, TCriterion value) where TData : IComparable <TData>, IBeneath <TCriterion> { throw new NotImplementedException(); }
/// <summary> /// Appends the table, built from data contained in the list and preceded by the header, /// to the end of the text file. /// THE STUDENT SHOULD IMPLEMENT THIS METHOD ACCORDING THE TASK. /// </summary> /// <param name="fileName">The name of the text file</param> /// <param name="header">The header of the table</param> /// <param name="list">The list from which the table to be formed</param> public static void PrintToFile(string fileName, string header, LinkList<Operation> list) { throw new NotImplementedException(); }
/// <summary> /// Finds the smallest quantity value in the list. /// THE STUDENT SHOULD IMPLEMENT THIS METHOD ACCORDING THE TASK. /// </summary> /// <param name="list">The data for the calculation.</param> /// <returns>The smallest quantity value.</returns> public static int MinQuantity(LinkList<Operation> list) { throw new NotImplementedException(); }