These derived classes reflect the specifics of a particular program. After the throw keyword, you should place object of System.Exception class or classes derived from it. To generate exception, throw operator is used. An exception is an event that occurs during the execution of a program that disrupts the normal flow of instructions. Exceptions allow programmer to separate points where runtime errors occur from points of error handling. Using exceptions handling mechanism is a very important part of programming on all modern object-oriented languages. If the element already exists, it accessed in common way.Ĭreate a constructor without parameters, an indexer, a property that returns the index of the last element, method providing an iterator, and override ToString() method. If certain elements are there, they are retained, and an array complemented by new elements. For example, if you create an empty array a, the first reference to the element a (whether for reading or for writing) provide extensions of the array so that it contains n + 1 element with indices from 0 to n-th inclusive. 1.8 Creating a "Flexible" Array (Advanced Task)Ĭreate a generic class for representation of one-dimensional array that automatically expands when user accesses a nonexistent element. Display all the different letters in alphabetical order. 1.7 Working with Associative ArrayĮnter a sentence and calculate the number of different letters in a sentence. Print elements of the set, sorted in ascending order. 1.6 Working with SetĮnter count of elements that will be stored in a set of integers and the range of numbers. You should implement two versions: based on an array and based on a list. The Main() function should contain testing of all elements of the class. method providing iterator that enables traversal of elements using foreach.overloaded operator of conversion to string ( operator string).constructor with parameters from and some array (with params attribute).constructor with parameters from and to that creates an empty array.read only properties From and To (you can store From and calculate To).The class should contain the following elements: These values can be both positive and negative. 1.5 Creating Your Own ContainerĬreate a generic class that represent one-dimensional array of elements whose index varies from a specified value From to a value To inclusive. Implement these functions for arrays and lists. replacement of some group with elements of other array (list).insert elements of another array (list) in the specified location.swap of all neighbour elements (with even and odd indices).1.4 Creation of a Library that Provides Generic Functions for Working with Arrays and ListsĬreate a static class with generic static methods that implement the following functionality: Create objects and perform their serialization into XML document and deserialization from XML document. 1.3 Implementation of Serialization and DeserializationĬreate classes Student and Academic group (with an array of students as a field). 1.2 Working with Text Filesĭevelop a program that performs copying from one file to another file only strings whose length is less than some integer value. Implement testing additional data representation in three ways: Add reference to this library to new console application. Reproduce previous laboratory work tasks.Īll classes except class with Main() function should be placed in a separate library. To store the entities in the group, use list instead of an array. To work with XML documents use serialization and deserialization. Implement functions of saving data in XML format and loading data from XML document. Within the class, which represents group of entities, add the following features of sorting: Entity Previous Next ua Laboratory Training 3 Generic Classes and Methods 1 Training Tasks 1.1 Individual TaskĮxpand the program, which was created in the previous labs, by converting entity class into generic class, so it could possible to use different types for representation of additional data (string, newly created structure, some class).
0 Comments
Leave a Reply. |